Skip to content
StackDecode
System Design
12. Reliability and Fault ToleranceAnimated

Circuit Breakers

Fail fast when a dependency is unhealthy.

The idea

Open the circuit after repeated failures so callers stop waiting and the dependency can recover.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

CLOSEDclosed: allow callsopen: fail fasthalf-open: let one trial call throughtick 1: successdownstream service: UP
  • closed
  • open
  • half-open

Service healthy: calls pass through. Failures are counted.

tick:
1
1/24

The downstream service is down from tick 7 to 14.

Step by step

  1. 1Monitor calls
  2. 2Open at a failure threshold
  3. 3Fail fast
  4. 4Probe and close

Where it is used

Resilient service calls.

Watch out for

Poor thresholds cause flapping.

Related