Architecturechapter 5 of 5 · 3 lessons
Circuit Breaker
Automatically stop calling a failing dependency to give it time to recover.
The most dangerous dependency in a distributed system is not the one that fails fast. It is the one that fails slowly, holding your threads hostage for thirty seconds at a time until your healthy service dies of somebody else's illness.
A circuit breaker notices that a dependency is sick and stops calling it, trading fresh answers for survival. The trade is the uncomfortable part, because you are choosing to fail requests you might have been able to serve, on the theory that failing a few now beats failing everything in ninety seconds.
Lessons
3 in this chapter- How Failures CascadeSlow dependencies eat threads, and eaten threads take healthy services down with them.2 min
- Closed, Open, Half-OpenA per-dependency state machine that fails fast when sick and probes its way back to health.3 min
- Tuning and FallbacksA breaker decides when to stop calling. The fallback decides what your users see instead.3 min