Circuit Breakers

The three-state machine, why fail-fast beats hanging, and how circuit breakers prevent cascading failures.

Overview

Why circuit breakers exist

The circuit breaker is a pattern from Michael Nygard's *Release It!* (2007). It became canonical through Netflix Hystrix and now ships in service meshes such as Istio and Linkerd.

The principle: when a downstream dependency is failing, stop calling it for a while. The failing dependency gets a chance to recover, and your service stops wasting threads and CPU on doomed calls. A breaker does this with a small state machine of three states, CLOSED, OPEN and HALF-OPEN, described below.

> [!IMPORTANT] An open breaker protects both sides: your service keeps its threads, and the sick dependency gets room to recover.

Key concepts

  • Three-state machine
  • Fail-fast
  • resilience4j
  • Istio outlierDetection
  • Failure threshold + min requests
  • Fallback

Interview questions

  • Walk me through the circuit breaker state machine.
  • How does Istio's circuit breaker compare to Hystrix?
  • When does a circuit breaker hurt instead of help?

Sign up free to read the full topic

More SRE topics

Start free on Cariara · Coding problems · System design studio