Archivereliability
Circuit Breakers Are for Fast Failure, Not for Healing
They stop sending traffic to a failing dependency so it can recover, and so your own threads do not pile up.
- Published
- Reading time
- 1 min read
A circuit breaker tracks failures to a dependency and, past a threshold, rejects calls immediately instead of waiting for timeouts. After a cool-down it allows a trial request (half-open) and closes if that succeeds.
What it buys
- Latency protection: fail in microseconds instead of waiting for a 30 s timeout.
- Resource protection: no thread or connection pool exhaustion on doomed calls.
- Recovery room: less load on the dependency while it restarts or scales.
What it does not do
It does not fix the dependency, and a breaker that opens for a shared dependency can cascade: every caller trips at once, then every caller probes at once. Jitter the half-open probes and use per-dependency thresholds.
Design details
- Count failures by outcome class, not all errors (a 404 is not a dependency failure).
- Use a sliding window, not a lifetime counter.
- Return a deliberate fallback (cached value, partial response), not a 500.
- Combine with bulkheads so one dependency cannot consume all workers.
Takeaway: breakers convert slow failure into fast failure. Pair them with fallbacks and concurrency isolation.