Skip to content
Merged
37 changes: 37 additions & 0 deletions api/v1alpha1/connection_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,43 @@ type BackendConnection struct {
// +optional
// +notImplementedHide
SocketBufferLimit *resource.Quantity `json:"socketBufferLimit,omitempty"`

// Preconnect configures proactive upstream connections to reduce latency by establishing
// connections before they’re needed and avoiding connection establishment overhead.
//
// If unset, Envoy will fetch connections as needed to serve in-flight requests.
//
// +optional
Preconnect *PreconnectPolicy `json:"preconnect,omitempty"`
}

// Preconnect configures proactive upstream connections to avoid
// connection establishment overhead and reduce latency.
type PreconnectPolicy struct {
// PerUpstreamPercent configures how many additional connections to maintain per
// upstream endpoint, useful for high-QPS or latency sensitive services. Expressed as a
// percentage over the connections required by active streams
// (e.g. 0 = preconnect disabled 5 = 1.05x connections per-upstream, 100 = 2.00×).
//
// Maximum allowed is 200. When both PerUpstreamPercent and
// PredictivePercent are set, Envoy ensures both are satisfied (max of the two).
//
// +kubebuilder:validation:Maximum=200
// +optional
PerUpstreamPercent *uint32 `json:"perUpstreamPercent,omitempty"`

// PredictivePercent configures how many additional connections to maintain
// across the cluster by anticipating which upstream endpoint the load balancer
// will select next, useful for low-QPS services. Relies on deterministic
// loadbalancing and is only supported with Random or RoundRobin.
// Expressed as a percentage over the connections required by active streams
// (e.g. 0 = preconnect disabled, 5 = 1.05× connections across the cluster, 100 = 2.00×).
//
// When both PerUpstreamPercent and PredictivePercent are
// set Envoy ensures both are satisfied per host (max of the two).
//
// +optional
PredictivePercent *uint32 `json:"predictivePercent,omitempty"`
}

type ConnectionLimit struct {
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ type BackendCluster struct {

// ClusterSettings provides the various knobs that can be set to control how traffic to a given
// backend will be configured.
//
// +kubebuilder:validation:XValidation:rule="!((has(self.connection) && has(self.connection.preconnect) && has(self.connection.preconnect.predictivePercent)) && !(has(self.loadBalancer) && has(self.loadBalancer.type) && self.loadBalancer.type in ['Random', 'RoundRobin']))",message="predictivePercent in preconnect policy only works with RoundRobin or Random load balancers"
type ClusterSettings struct {
// LoadBalancer policy to apply when routing traffic from the gateway to
// the backend endpoints. Defaults to `LeastRequest`.
Expand Down
30 changes: 30 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,39 @@ spec:
For example, 20Mi, 1Gi, 256Ki etc.
Note: that when the suffix is not provided, the value is interpreted as bytes.
x-kubernetes-int-or-string: true
preconnect:
description: |-
Preconnect configures proactive upstream connections to reduce latency by establishing
connections before they’re needed and avoiding connection establishment overhead.

If unset, Envoy will fetch connections as needed to serve in-flight requests.
properties:
perUpstreamPercent:
description: |-
PerUpstreamPercent configures how many additional connections to maintain per
upstream endpoint, useful for high-QPS or latency sensitive services. Expressed as a
percentage over the connections required by active streams
(e.g. 0 = preconnect disabled 5 = 1.05x connections per-upstream, 100 = 2.00×).

Maximum allowed is 200. When both PerUpstreamPercent and
PredictivePercent are set, Envoy ensures both are satisfied (max of the two).
format: int32
maximum: 200
type: integer
predictivePercent:
description: |-
PredictivePercent configures how many additional connections to maintain
across the cluster by anticipating which upstream endpoint the load balancer
will select next, useful for low-QPS services. Relies on deterministic
loadbalancing and is only supported with Random or RoundRobin.
Expressed as a percentage over the connections required by active streams
(e.g. 0 = preconnect disabled, 5 = 1.05× connections across the cluster, 100 = 2.00×).

When both PerUpstreamPercent and PredictivePercent are
set Envoy ensures both are satisfied per host (max of the two).
format: int32
type: integer
type: object
socketBufferLimit:
allOf:
- pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
Expand Down Expand Up @@ -2265,6 +2298,12 @@ spec:
: true'
- message: either compression or compressor can be set, not both
rule: '!has(self.compression) || !has(self.compressor)'
- message: predictivePercent in preconnect policy only works with RoundRobin
or Random load balancers
rule: '!((has(self.connection) && has(self.connection.preconnect) &&
has(self.connection.preconnect.predictivePercent)) && !(has(self.loadBalancer)
&& has(self.loadBalancer.type) && self.loadBalancer.type in [''Random'',
''RoundRobin'']))'
status:
description: status defines the current status of BackendTrafficPolicy.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,39 @@ spec:
For example, 20Mi, 1Gi, 256Ki etc.
Note: that when the suffix is not provided, the value is interpreted as bytes.
x-kubernetes-int-or-string: true
preconnect:
description: |-
Preconnect configures proactive upstream connections to reduce latency by establishing
connections before they’re needed and avoiding connection establishment overhead.

If unset, Envoy will fetch connections as needed to serve in-flight requests.
properties:
perUpstreamPercent:
description: |-
PerUpstreamPercent configures how many additional connections to maintain per
upstream endpoint, useful for high-QPS or latency sensitive services. Expressed as a
percentage over the connections required by active streams
(e.g. 0 = preconnect disabled 5 = 1.05x connections per-upstream, 100 = 2.00×).

Maximum allowed is 200. When both PerUpstreamPercent and
PredictivePercent are set, Envoy ensures both are satisfied (max of the two).
format: int32
maximum: 200
type: integer
predictivePercent:
description: |-
PredictivePercent configures how many additional connections to maintain
across the cluster by anticipating which upstream endpoint the load balancer
will select next, useful for low-QPS services. Relies on deterministic
loadbalancing and is only supported with Random or RoundRobin.
Expressed as a percentage over the connections required by active streams
(e.g. 0 = preconnect disabled, 5 = 1.05× connections across the cluster, 100 = 2.00×).

When both PerUpstreamPercent and PredictivePercent are
set Envoy ensures both are satisfied per host (max of the two).
format: int32
type: integer
type: object
socketBufferLimit:
allOf:
- pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
Expand Down Expand Up @@ -1059,6 +1092,13 @@ spec:
type: object
type: object
type: object
x-kubernetes-validations:
- message: predictivePercent in preconnect policy only works
with RoundRobin or Random load balancers
rule: '!((has(self.connection) && has(self.connection.preconnect)
&& has(self.connection.preconnect.predictivePercent)) &&
!(has(self.loadBalancer) && has(self.loadBalancer.type)
&& self.loadBalancer.type in [''Random'', ''RoundRobin'']))'
failOpen:
default: false
description: |-
Expand Down
Loading
Loading