Circuit Breaker
maang.io System Design Series
A circuit breaker wraps calls to a dependency and, when failures cross a threshold, "trips" — failing fast instead of hammering a service that's already down. Like an electrical breaker, it moves through closed → open → half-open states, probing for recovery before letting traffic flow again. It's the pattern that stops one slow dependency from exhausting threads and cascading into a full outage.
This deep dive comes in three parts:
- Foundations & Core Concepts — the three states and the failure threshold.
- Internals — rolling-window failure counting, fallbacks, and related patterns (timeouts, bulkheads), with worked numbers.
- Interview — Staff/Principal Q&A: preventing cascades and library vs service-mesh placement.