Stop calling what is already failing
When a dependency hangs, every call waits for its timeout. Callers pile up, resources run out, and the failure spreads. A breaker stops most of those calls early.
Follow the requestScene 1 / 5
While the dependency is healthy, the breaker forwards each call and stays closed.
Illustrative guided sequence, not a simulation or a benchmark.
01 / 05
Healthy calls pass through
Two calls arrive. The breaker is closed, so it forwards each request to the dependency and returns the reply. Nothing is counted as a failure.
What you will learn
- Explain what the closed, open and half-open states do with each call.
- Describe how consecutive failures open the breaker and successful probes close it.
- Explain why a fallback answer is not the same as a successful call.
- Explain why a breaker does not replace a timeout on each call.
- Name a case where a breaker is the wrong tool.
Transcript
- Healthy calls pass through. Two calls arrive. The breaker is closed, so it forwards each request to the dependency and returns the reply. Nothing is counted as a failure.On screen: While the dependency is healthy, the breaker forwards each call and stays closed.
- Failures are counted in a row. The dependency starts returning errors. The breaker counts them in a row, and any success would clear the count. This lab's threshold is five, so the fifth consecutive error opens the breaker.On screen: Each error adds one to a run of consecutive failures. At five in a row, the breaker opens.
- Open: fail fast or fall back. The breaker is open, so calls stop at the breaker and the client gets a fallback straight away, such as a cached or default answer. A fallback is not a success for the dependency. The open period sets how long the breaker waits before it tries again.On screen: While open, the breaker answers at once with a fallback. The dependency receives no calls.
- Half-open: probes, then close. After the open period, the breaker lets up to two real calls through as probes. Each probe reaches the dependency, and its reply returns through the breaker. Both succeed, so the breaker closes and normal calls resume. Calls beyond the probe limit are short-circuited, and a failed probe would return the breaker to open.On screen: Half-open lets a few real calls through as probes.
- Timeouts still bound each call. A call that never returns holds its caller's resources. A timeout ends each attempt and marks it as a failure, which the breaker can count. The breaker decides whether to send later calls; the timeout is what bounds this one.On screen: A breaker does not replace timeouts. Each call still needs a deadline, so a slow call ends as a counted failure.
Sources
- Circuit Breaker pattern (Microsoft Learn) accessed 2026-11-26
- CircuitBreaker (martinfowler.com) accessed 2026-11-26
- Timeouts, retries and backoff with jitter (Amazon Builders' Library) accessed 2026-11-26
Under the hood
How a breaker counts consecutive failures, opens to fail fast or fall back, probes a dependency in half-open, and why it still needs timeouts.
Trade-offs
- Calls stop reaching a struggling dependency, which gives it room to recover and keeps callers from waiting.
- A fallback answers quickly, but the caller must handle it. A fallback is not a success for the dependency.
- The breaker adds state, thresholds and timers that need testing, logging and tuning.
When not to use it
- Local, in-process calls where no shared resource needs protecting; the breaker adds overhead for no gain.
- A dependency that fails only briefly and already works well with bounded retries.
- As a replacement for timeouts: a call with no deadline can still hold resources while the breaker waits.
Limitations of this lesson
- The lab counts consecutive failures, not a failure rate over a time window (many breakers use a time-window failure count), and it has no retries.
- A timed-out call is counted once as a timeout. Real systems differ in how they classify slow calls.
- Fault window, timings and recovery are illustrative, not measured outages or benchmarks.
- One breaker protects one client and one dependency here. Shared breakers across many clients are not modelled.
- Real breakers add modal behaviour that is hard to test; the lesson does not cover that testing.
- Fallback is served only for calls the open breaker blocks; failed or timed-out calls get none. Extra calls in half-open beyond the probe limit are short-circuited.