Circuit breakers prevent cascading failures by short-circuiting requests when upstream services are overwhelmed. When connection or request thresholds are exceeded, Envoy immediately returns errors instead of queuing more requests.
Envoy’s default circuit breaker limits (1024 connections, 1024 pending requests) may be too low for high-traffic environments. Without proper tuning:
Circuit breakers allow you to set appropriate limits based on your traffic patterns and upstream capacity.
Circuit breakers can be configured at two levels:
Config CRD): Applies to all tenants as the defaultTenant CRD): Overrides global config for specific tenantsTenant-level configuration takes precedence over global configuration.
| Field | Type | Default | Description |
|---|---|---|---|
maxConnections | int64 | 1024 | Maximum connections to all upstream endpoints |
maxPendingRequests | int64 | 1024 | Maximum requests queued waiting for a connection |
maxParallelRequests | int64 | 1024 | Maximum parallel requests (HTTP/2, gRPC multiplexing) |
maxParallelRetries | int64 | 3 | Maximum parallel retry attempts |
maxRequestsPerConnection | int64 | - | Maximum requests per connection before closing |
perEndpoint.maxConnections | int64 | - | Maximum connections per individual endpoint |
Configure circuit breakers globally in the Config CRD under spec.circuitBreaker:
apiVersion: kubelb.k8c.io/v1alpha1
kind: Config
metadata:
name: default
namespace: kubelb
spec:
circuitBreaker:
maxConnections: 10000
maxPendingRequests: 5000
maxParallelRequests: 10000
maxParallelRetries: 10
maxRequestsPerConnection: 1000
perEndpoint:
maxConnections: 500
Override global settings for specific tenants in the Tenant CRD:
apiVersion: kubelb.k8c.io/v1alpha1
kind: Tenant
metadata:
name: high-traffic-tenant
namespace: kubelb
spec:
circuitBreaker:
maxConnections: 50000
maxPendingRequests: 25000
maxParallelRequests: 50000
maxParallelRetries: 20
When thresholds are exceeded:
x-envoy-overloaded header to responsesMonitor for x-envoy-overloaded headers to detect when circuit breakers are triggering.
The same fields are tuned per scenario; only the values change:
Config): maxConnections: 100000, maxPendingRequests: 50000, maxParallelRequests: 100000, maxParallelRetries: 50, perEndpoint.maxConnections: 2000.Tenant): maxConnections: 500, maxPendingRequests: 250, maxParallelRequests: 500, maxParallelRetries: 3, maxRequestsPerConnection: 100.Tenant): keep maxConnections low (for example 1000) and maxParallelRequests high (for example 50000), because requests are multiplexed over few connections; maxPendingRequests: 10000, maxParallelRetries: 10.Track circuit breaker metrics to tune your configuration:
envoy_cluster_upstream_cx_overflow: Connections rejected due to maxConnectionsenvoy_cluster_upstream_rq_pending_overflow: Requests rejected due to maxPendingRequestsenvoy_cluster_upstream_rq_retry_overflow: Retries rejected due to maxParallelRetries