The circuit breaker is a resilience pattern for software that calls remote services. Its canonical write-up is Martin Fowler’s bliki article “CircuitBreaker,” published on March 6, 2014, which describes a wrapper around a protected call that monitors for failures. Once failures cross a threshold, the breaker “trips” and subsequent calls return immediately without attempting the operation, sparing both the caller and the failing dependency.
The problem it solves is cascading failure. When a downstream service becomes slow or unresponsive, every call to it ties up a thread or connection while it waits for a timeout. Under load, those waiting calls pile up until the caller itself runs out of resources and fails, and its callers in turn fail, so a single sick component can topple an entire system. Fowler credits Michael Nygard’s book “Release It!” with popularizing the circuit breaker “to prevent this kind of catastrophic cascade.”
The pattern borrows its name and behavior from an electrical circuit breaker. In the closed state, calls flow through normally while the breaker counts failures. When failures exceed the threshold, the breaker moves to the open state and short-circuits every call, failing fast rather than waiting on a dependency that is clearly in trouble. After a cooldown the breaker enters a half-open state, allowing a trial call through; if it succeeds the breaker closes and normal traffic resumes, and if it fails the breaker opens again and the timer restarts.
Failing fast has a second benefit beyond protecting the caller: it gives the troubled service breathing room. A dependency that is overloaded recovers faster when the flood of requests is cut off, and a circuit breaker does exactly that. It also creates a clean place to hang a fallback. When the breaker is open, instead of returning an error the caller can serve cached data, a default value, or a degraded response, so the user experience stays acceptable while the underlying problem is sorted out.
The pattern became a staple of the microservices era, where an application is a web of services calling one another over the network and any one of them can fail at any time. Netflix’s Hystrix library, released as open source, was an influential implementation that combined circuit breaking with isolation and fallbacks, and it helped make the pattern standard practice. The core idea endures regardless of the library: a system should detect when a dependency is failing and stop calling it, rather than politely waiting in line for a service that cannot answer.