Circuit breaker around flaky dependencies

9633
0

Retries alone can make an outage worse: if a dependency is hard failing, retries just add load. A circuit breaker adds a simple state machine: closed (normal), open (fail fast), and half-open (probe). I like gobreaker because it’s small and predictable. The important detail is what counts as a failure: timeouts and 5xx responses should trip the breaker; validation errors should not. I also emit breaker state changes as logs/metrics so you can see when the system is protecting itself. The result is better tail latency and less cascading failure, especially for high QPS services that call a single upstream. Pair it with request-level context.WithTimeout and you get a clean “fail fast” behavior.