Skip to main content

Circuit Breaking

Circuit breaking is a resilience pattern that stops sending requests to a failing service after repeated errors, so the failure cannot cascade to callers. In Istio it is configured in a DestinationRule through connection pool limits and outlier detection.

The problem it solves

Without circuit breaking, a slow or failing dependency makes callers wait on timeouts. Their thread pools fill, they become slow, and their own callers fail next. One unhealthy payments service can degrade a whole checkout flow.

With circuit breaking, the proxy fails fast or removes the unhealthy endpoint so the caller stays responsive.

stateDiagram-v2 [*] --> Healthy Healthy --> Ejected: 5 consecutive 5xx Ejected --> Probation: ejection time ends Probation --> Healthy: request succeeds Probation --> Ejected: request fails

Istio configuration

YAML
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: payments-circuit-breaker
namespace: production
spec:
host: payments-service
trafficPolicy:
connectionPool:
http:
http1MaxPendingRequests: 100 # queue limit before fast rejection
maxRequestsPerConnection: 10
outlierDetection:
consecutive5xxErrors: 5
interval: 10s
baseEjectionTime: 30s
maxEjectionPercent: 50

How ejection really works

  • Detection runs per endpoint (per pod), not per service. Healthy pods keep receiving traffic.
  • Ejection time is baseEjectionTime multiplied by how many times that endpoint has been ejected, so repeat offenders stay out longer.
  • Each calling sidecar keeps its own view of endpoint health, so one caller's ejection decision is not automatically shared with every other caller.
  • maxEjectionPercent caps how much of the pool can be ejected. Istio's default is 10 percent.

Istio vs library-based breakers

Istio outlier detection Resilience4j or Hystrix
Where it runs Sidecar proxy Application code
Code changes None Library integration
Tip

Set baseEjectionTime to at least 30 seconds so an unhealthy pod has time to recover or be restarted by its liveness probe.

Common Mistake

Setting maxEjectionPercent: 100. If every pod fails, the service becomes completely unreachable instead of degraded.

Frequently Asked Questions

How is circuit breaking different from retries?

Retries repeat a failed request, which helps with transient blips but adds load to an already struggling service. Circuit breaking tracks failure patterns and stops sending traffic for a cooldown, protecting both sides. They complement each other.

Why did my healthy service get ejected?

Thresholds that are too sensitive can eject pods during a brief spike, which concentrates traffic on the remaining pods and can cascade. Tune thresholds against real production variance, not only load tests.

Does Istio circuit break per service or per pod?

Per pod. Outlier detection ejects individual failing endpoints from the load balancing pool while the rest of the service keeps serving.

Found a mistake, an outdated step or a broken link?