Lab · Reliability

Circuit breaker

Service A calls Service B. When B keeps failing, a circuit breaker in A stops calling it for a while and returns a fallback instead — protecting both services. Break B and watch the breaker move through its three states.

Try it

Lab time 3.0 s
timeout 1 swhen openUsers, 6 req/sUsers6 req/sService A, breaker closed, CLOSEDService Abreaker closed3 waiting on callsCLOSEDService B (dependency), healthyService B (dependency)healthyworking on 3Fallback, cached or default answerFallbackcached or default answer
  • Users — 6 req/s — healthy
  • Service A — breaker closed — healthy — CLOSED — 3 waiting on calls
  • Service B (dependency) — healthy — healthy — working on 3
  • Fallback — cached or default answer — healthy
  • Request
  • Response
  • Error / rejected
  • Fallback
Breaker
Closed
Healthy: calls pass through
Calls reaching B
6/s
B is working on
3
Failed
1
1 errors · 0 timeouts
Fallbacks
0
answered without calling B
wait
830 ms

Numbers add up:19 calls = 15 succeeded + 1 failed + 0 fallbacks + 3 in flightThe lab checks this sum as it runs, so a counting mistake would show here.

Controls

Service B
Health

Answers in ~200 ms. Occasional errors (2%).

Traffic
6/s
Breaker settings
50%
5 s
3

Breaker state

State machine
50%+ of last 10 failafter 5 sa trial fails3 trials succeedClosed● currentOpenfail fastHalf-opentrial calls
  1. 0.0s Closed — start
Calls reaching Service B per second (shaded: breaker open)
02.557.5101s2s3s
Show data table
TimeCalls to B/s
1s8
1s4
2s8
2s4
3s8
3s6

What just happened

Nothing yet. Start traffic or run an experiment.

Incident drill: Service B turns slow while the breaker is off

Service A calls Service B 10 times a second, and the circuit breaker is switched off. Something will go wrong soon. Watch "Failed" and "B is working on". The drill takes about 2 minutes at the default speed; the speed control above the diagram makes it faster.

What this model simplifies
  • The failure window counts the last 10 calls and needs at least 5 before it can trip. Libraries such as Resilience4j also offer time-based windows and slow-call thresholds.
  • One breaker for one dependency. Real services keep a separate breaker per downstream dependency (and sometimes per endpoint).
  • The fallback always succeeds. In practice a fallback can be stale, partial, or unavailable too — design what users see when it is.