How it works · 24 of 49 Core
What is the circuit breaker pattern?
Stop calling what is down
Circuit breakers: A circuit breaker sits in front of a remote call and counts failures. After a threshold it *trips* (open): calls fail instantly with a fallback instead of waiting for a timeout, so the caller's workers stay free and the failing service gets room to recover. After a pause it lets one trial call through (half-open): success closes it, failure opens it again. Without one, a dead dependency holds every worker in a timeout and takes down pages that never needed it.
Loading the animation…
Say it like this A circuit breaker counts failures on a remote call and, past a threshold, fails new calls instantly with a fallback instead of waiting on timeouts, then lets one trial call through to see if the service is back; it keeps a dead dependency from tying up every worker.
Under the hood — for builders
- The sources, in their words
- Martin Fowler ("CircuitBreaker", 2014): "Once the failures reach a certain threshold, the circuit breaker trips"; the half-open circuit "is ready to make a real call as trial to see if the problem is fixed." Microsoft ("Circuit Breaker pattern", Azure Architecture Center, 2025): blocked requests "might hold critical system resources, such as memory, threads, and database connections."
- Three states
- Trip: the switch from closed to open. Fallback: what a caller returns instead, such as a default or cached answer (Microsoft: the open state "can return a default value").
- Run here: the scene's numbers
- Checkout has 20 workers and gets 20 checkouts a second (each calls Inventory) plus 80 home-page requests (10 ms, no call). Inventory is down for 60 s; a call then waits 5 s to time out. A request that waits more than 2 s for a worker gives up. Breaker: trips after 3 failures, open 10 s, then one trial call. Home-page requests served during the outage:
- Breaker and retry together
- Microsoft: retry "through a circuit breaker", and stop retrying when the breaker says the fault "isn't transient". E1's retries stop at an open breaker.
- What should trip it
- Fowler: "Not all errors should trip the circuit": a 404 is an answer, a timeout or 503 is not. Microsoft: a 429 or 503 may carry how long to wait.
- Measure it
- Breaker state changes per hour · time open · calls short-circuited · trial calls failed. Fowler: "Any change in breaker state should be logged."
- Watch out
- One breaker per independent dependency, not per whole database (Microsoft: one shard may be fine). Not for local calls, and not instead of error handling.
- Sources
- Martin Fowler, "CircuitBreaker", 2014 · Microsoft, "Circuit Breaker pattern", Azure Architecture Center, 2025 · both read in session · worker-pool simulation, Python, 19 Nov 2026.
What happens in the circuit breakers animation, step by step?
- Checkout calls Inventory across the bridge. Each call holds one of Checkout's 20 workers until the answer comes.
- Inventory is down. Each call waits 5 s for a timeout, every worker ends up waiting, and even the home page stalls.
- After three failures the breaker trips: the bridge rises and callers get an instant "not now". Workers are free again.
- Your turn: the castle is being repaired. Tap it to send one scout across.
- One scout succeeded, so the bridge comes down. Only one call was risked while the castle was weak.
- A breaker needs a fallback for "not now" and an alert when it trips. Next: keep one overload from sinking the rest.
What everyday example explains circuit breakers?
Raising the drawbridge and sending one scout. Nobody else crosses until the scout comes back safe.
Why should a team care about circuit breakers?
The outage that spreads is rarely the one that started it: a slow dependency holding every thread is how one broken service takes down pages that never call it. Breakers decide that in milliseconds instead of timeouts.