Why it matters

Without circuit breakers, one slow service takes down its callers, which take down their callers. With circuit breakers, failures stay contained. Every microservice architecture needs them.

Advertisement

The architecture

States: Closed (normal, requests pass through), Open (short-circuited, requests fail immediately), Half-Open (test if downstream recovered).

Transitions: Closed → Open when failure rate exceeds threshold. Open → Half-Open after a timeout. Half-Open → Closed on success, back to Open on failure.

Circuit breaker statesClosednormal, count failuresOpenfail fastHalf-Openprobe recoveryThreshold + timeout are the tunables; libraries like Hystrix, Resilience4j, Envoy implement this
Three-state machine.
Advertisement

How it works end to end

Failure detection: rolling window of recent requests. Count failures vs successes. If failure percentage exceeds threshold, open the circuit.

Half-open behavior: after cooldown, allow limited traffic through. If it succeeds, close the circuit. If it fails, reopen.

Bulkhead: often paired with circuit breaker. Isolates resources per dependency so a failing dependency can't consume all threads/connections.