Skip to content
StackDecode
System Design
11. Microservices ArchitectureAnimated

Circuit Breaker Pattern

Stop calling a failing service for a while.

The idea

After repeated failures, the breaker opens and fails fast, then tests recovery.

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. 1Count failures
  2. 2Open at a threshold
  3. 3Fail fast while open
  4. 4Try a trial call and close if healthy

Where it is used

Calls to remote services.

Watch out for

Tune thresholds, or it opens too early or too late.

Related