Skip to content

Commit

Permalink
feat: configure overload manager (#3082)
Browse files Browse the repository at this point in the history
* feat: support overload manager

Signed-off-by: Shahar Harari <shahar.harari@sap.com>

* add a test case to increase coverage

Signed-off-by: Shahar Harari <shahar.harari@sap.com>

---------

Signed-off-by: Shahar Harari <shahar.harari@sap.com>
  • Loading branch information
shahar-h authored Apr 5, 2024
1 parent 11f56fd commit 07f8a47
Show file tree
Hide file tree
Showing 35 changed files with 864 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ envoyProxy:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
logging: {}
status: {}
gatewayClass:
Expand Down Expand Up @@ -508,6 +515,13 @@ xds:
envoy.restart_features.use_eds_cache_for_ads: true
re2.max_program_size.error_level: 4294967295
re2.max_program_size.warn_level: 1000
overloadManager:
refreshInterval: 0.250s
resourceMonitors:
- name: envoy.resource_monitors.global_downstream_max_connections
typedConfig:
'@type': type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
maxActiveDownstreamConnections: "50000"
staticResources:
clusters:
- connectTimeout: 0.250s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
}
]
},
"overloadManager": {
"refreshInterval": "0.250s",
"resourceMonitors": [
{
"name": "envoy.resource_monitors.global_downstream_max_connections",
"typedConfig": {
"@type": "type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig",
"maxActiveDownstreamConnections": "50000"
}
}
]
},
"staticResources": {
"clusters": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ xds:
envoy.restart_features.use_eds_cache_for_ads: true
re2.max_program_size.error_level: 4294967295
re2.max_program_size.warn_level: 1000
overloadManager:
refreshInterval: 0.250s
resourceMonitors:
- name: envoy.resource_monitors.global_downstream_max_connections
typedConfig:
'@type': type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
maxActiveDownstreamConnections: "50000"
staticResources:
clusters:
- connectTimeout: 0.250s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ xds:
envoy.restart_features.use_eds_cache_for_ads: true
re2.max_program_size.error_level: 4294967295
re2.max_program_size.warn_level: 1000
overloadManager:
refreshInterval: 0.250s
resourceMonitors:
- name: envoy.resource_monitors.global_downstream_max_connections
typedConfig:
'@type': type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
maxActiveDownstreamConnections: "50000"
staticResources:
clusters:
- connectTimeout: 0.250s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
}
]
},
"overloadManager": {
"refreshInterval": "0.250s",
"resourceMonitors": [
{
"name": "envoy.resource_monitors.global_downstream_max_connections",
"typedConfig": {
"@type": "type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig",
"maxActiveDownstreamConnections": "50000"
}
}
]
},
"staticResources": {
"clusters": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ xds:
envoy.restart_features.use_eds_cache_for_ads: true
re2.max_program_size.error_level: 4294967295
re2.max_program_size.warn_level: 1000
overloadManager:
refreshInterval: 0.250s
resourceMonitors:
- name: envoy.resource_monitors.global_downstream_max_connections
typedConfig:
'@type': type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
maxActiveDownstreamConnections: "50000"
staticResources:
clusters:
- connectTimeout: 0.250s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ xds:
envoy.restart_features.use_eds_cache_for_ads: true
re2.max_program_size.error_level: 4294967295
re2.max_program_size.warn_level: 1000
overloadManager:
refreshInterval: 0.250s
resourceMonitors:
- name: envoy.resource_monitors.global_downstream_max_connections
typedConfig:
'@type': type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
maxActiveDownstreamConnections: "50000"
staticResources:
clusters:
- connectTimeout: 0.250s
Expand Down
23 changes: 22 additions & 1 deletion internal/infrastructure/kubernetes/proxy/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,14 @@ func expectedProxyContainers(infra *ir.ProxyInfra,
infra.Config.Spec.Telemetry != nil {
proxyMetrics = infra.Config.Spec.Telemetry.Metrics
}

maxHeapSizeBytes := caclulateMaxHeapSizeBytes(deploymentConfig.Container.Resources)

// Get the default Bootstrap
bootstrapConfigurations, err := bootstrap.GetRenderedBootstrapConfig(proxyMetrics)
bootstrapConfigurations, err := bootstrap.GetRenderedBootstrapConfig(&bootstrap.RenderBootsrapConfigOptions{
ProxyMetrics: proxyMetrics,
MaxHeapSizeBytes: maxHeapSizeBytes,
})
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -389,3 +395,18 @@ func expectedContainerEnv(containerSpec *egv1a1.KubernetesContainerSpec) []corev
return env
}
}

// caclulateMaxHeapSizeBytes calculates the maximum heap size in bytes as 80% of Envoy container memory limits.
// In case no limits are defined '0' is returned, which means no heap size limit is set.
func caclulateMaxHeapSizeBytes(envoyResourceRequirements *corev1.ResourceRequirements) uint64 {
if envoyResourceRequirements == nil || envoyResourceRequirements.Limits == nil {
return 0
}

if memLimit, ok := envoyResourceRequirements.Limits[corev1.ResourceMemory]; ok {
memLimitBytes := memLimit.Value()
return uint64(float64(memLimitBytes) * 0.8)
}

return 0
}
13 changes: 13 additions & 0 deletions internal/infrastructure/kubernetes/proxy/resource_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,19 @@ func TestDeployment(t *testing.T) {
infra: newTestInfra(),
extraArgs: []string{"--key1 val1", "--key2 val2"},
},
{
caseName: "with-empty-memory-limits",
infra: newTestInfra(),
deploy: &egv1a1.KubernetesDeploymentSpec{
Container: &egv1a1.KubernetesContainerSpec{
Resources: &corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("400m"),
},
},
},
},
},
}
for _, tc := range cases {
t.Run(tc.caseName, func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,28 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- name: "envoy.resource_monitors.fixed_heap"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.fixed_heap.v3.FixedHeapConfig
max_heap_size_bytes: 1717986918
actions:
- name: "envoy.overload_actions.shrink_heap"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.95
- name: "envoy.overload_actions.stop_accepting_requests"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.98
- --log-level warn
- --cpuset-threads
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,28 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- name: "envoy.resource_monitors.fixed_heap"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.fixed_heap.v3.FixedHeapConfig
max_heap_size_bytes: 1717986918
actions:
- name: "envoy.overload_actions.shrink_heap"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.95
- name: "envoy.overload_actions.stop_accepting_requests"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.98
- --log-level warn
- --cpuset-threads
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,28 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- name: "envoy.resource_monitors.fixed_heap"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.fixed_heap.v3.FixedHeapConfig
max_heap_size_bytes: 1717986918
actions:
- name: "envoy.overload_actions.shrink_heap"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.95
- name: "envoy.overload_actions.stop_accepting_requests"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.98
- --log-level warn
- --cpuset-threads
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- --log-level warn
- --cpuset-threads
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- --log-level warn
- --cpuset-threads
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,28 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- name: "envoy.resource_monitors.fixed_heap"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.fixed_heap.v3.FixedHeapConfig
max_heap_size_bytes: 1717986918
actions:
- name: "envoy.overload_actions.shrink_heap"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.95
- name: "envoy.overload_actions.stop_accepting_requests"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.98
- --log-level warn
- --cpuset-threads
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- --log-level warn
- --cpuset-threads
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- --log-level warn
- --cpuset-threads
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- --log-level warn
- --cpuset-threads
- --drain-time-s 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,28 @@ spec:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
- name: "envoy.resource_monitors.fixed_heap"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.fixed_heap.v3.FixedHeapConfig
max_heap_size_bytes: 1717986918
actions:
- name: "envoy.overload_actions.shrink_heap"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.95
- name: "envoy.overload_actions.stop_accepting_requests"
triggers:
- name: "envoy.resource_monitors.fixed_heap"
threshold:
value: 0.98
- --log-level warn
- --cpuset-threads
command:
Expand Down
Loading

0 comments on commit 07f8a47

Please sign in to comment.