Definition
What it is
A circuit breaker is a state machine that sits between a caller and a dependency. It counts successes and failures. When failures exceed a threshold, it "opens": further calls return an error immediately, without ever reaching the dependency. After a cooldown period, it enters a "half-open" state and lets a few test calls through. If those succeed, it closes and resumes normal operation; if they fail, it opens again.
The point is not to fix the dependency. The point is to stop wasting the caller's resources (threads, connections, latency budget) on calls that are almost certain to fail.
Why it matters
In a distributed system, every call is a potential liability. A database that has hit max connections will not answer faster under more load; a third-party API under rate limit will just keep returning 429. Without a breaker, the caller keeps trying, exhausts its own thread pool or connection pool, and eventually fails for a reason that has nothing to do with the actual bug.
A circuit breaker turns that cascade into a bounded failure. The caller responds quickly (even if with a degraded result), keeps serving healthy traffic, and recovers as soon as the dependency recovers.
The three states
State | Behaviour | Exit condition |
|---|---|---|
Closed | Calls pass, counters accumulate | Open on failures > threshold |
Open | Calls rejected immediately (fast-fail) | Closed→Half-open after cooldown |
Half-open | Limited test calls allowed | Closed if tests succeed, Open if they fail |
Resilience patterns side by side
Pattern | What it does | Trigger | Scope |
|---|---|---|---|
Retry | Re-attempts the same call | Transient failure | Operation |
Circuit breaker | Rejects calls to protect caller | Failure threshold | Dependency |
Switches to standby replica | Primary failure | Infrastructure | |
Failback | Returns to primary after recovery | Primary repaired | Infrastructure |
The state machine
stateDiagram-v2
[*] --> Closed
Closed --> Closed: call succeeds
Closed --> Open: failures > threshold
Open --> Open: calls rejected (fast fail)
Open --> HalfOpen: cooldown expires
HalfOpen --> Closed: test calls succeed
HalfOpen --> Open: test call fails
How to configure one well
A circuit breaker that helps, not hurts
Threshold based on error rate, not absolute count
50% errors over 20 calls is a better signal than "5 errors in a row".
Cooldown long enough to matter
30-60 seconds. Too short and the breaker flips repeatedly; too long and it delays recovery.
Always have a fallback
A cached value, a default response, a queued retry. Failing fast is fine; failing without a message is not.
Log every state change
Closed→Open is an incident signal. HalfOpen→Closed is a recovery signal. Both belong in your dashboards.
Per-dependency breakers, not global
A breaker around the payment gateway and a breaker around the recommendation service are independent.
Common failures
Origin
Wrap a protected function call in a circuit breaker object, which monitors for failures. Once the failures reach a certain threshold, the circuit breaker trips, and all further calls to the circuit breaker return with an error, without the protected call being made at all.
— Martin Fowler, *CircuitBreaker*, 2014
Evidence
FAQ
- Circuit breaker vs retry?
A retry re-attempts the call; a circuit breaker stops it. Use retries for transient failures inside the closed state, and a breaker to stop retries once failures become sustained.
- How many errors to open?
Depends on traffic. A common default is 50% error rate over a rolling 20-50 call window. Tune per dependency.
- What happens when the breaker is open?
Calls return immediately with an error or a fallback. No request reaches the dependency, so it has room to recover.
- Circuit breaker vs failover?
A breaker protects the caller from a dependency; failover moves the workload to a standby replica. They operate at different layers.
Connections
- retry
- failover
- backpressure
- rate-limiting
- graceful-degradation
● broader ● narrower ● related
Broader
reliabilityresilience-patterns
Related
- Retry
- Failover
- Backpressure
rate-limiting- Graceful degradation
Used in the garden
- 10 Forbidden Websites That Are Perfect for Creative Inspiration (2026) (1×)
- 10 Forbidden Websites That Will Blow Your Creativity (2026) (1×)
- Digital Trust: How Branding and Marketing Build the Currency of the Internet (1×)
- Brand Trust, Reputation, and Employer Branding: The Pillars of Credibility (1×)
Sources
Fowler, M. (2014). CircuitBreaker. https://martinfowler.com/bliki/CircuitBreaker.html
Nygard, M. T. (2018). Release It!, 2nd ed. https://pragprog.com/titles/mnee2/release-it-second-edition/
Microsoft Azure Architecture Center (2025). Circuit Breaker pattern. https://learn.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker
Netflix (2018). Hystrix. https://github.com/Netflix/Hystrix
Etymology
Origin: metaphor
circuit(noun): from Latin circuitus, "a going around"breaker(noun): electrical device that interrupts current flow on overload
Semantic network
● broader ● narrower ● related
Broader
reliabilityresilience-patterns
Related
- Retry
- Failover
- Backpressure
rate-limiting- Graceful degradation
Used in the garden
- 10 Forbidden Websites That Are Perfect for Creative Inspiration (2026) (1×)
- 10 Forbidden Websites That Will Blow Your Creativity (2026) (1×)
- Digital Trust: How Branding and Marketing Build the Currency of the Internet (1×)
- Brand Trust, Reputation, and Employer Branding: The Pillars of Credibility (1×)
Sources
Fowler, M. (2014). CircuitBreaker. https://martinfowler.com/bliki/CircuitBreaker.html
Nygard, M. T. (2018). Release It!, 2nd ed. https://pragprog.com/titles/mnee2/release-it-second-edition/
Microsoft Azure Architecture Center (2025). Circuit Breaker pattern. https://learn.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker