Circuit Breaker vs Retry with Backoff
People think a circuit breaker is just a limit on retries, and it is not. A retry tries one failed call again, waiting longer each time. A circuit breaker watches all calls to a service. Once too many fail, it stops sending any for a while. Retries help with a short blip. The breaker helps when a service is truly down.
Circuit Breaker Pattern
Stop calling a failing service for a while. Then trouble does not spread.
A circuit breaker stops calling a service that keeps failing. That keeps the failure from spreading. It counts errors on calls to that service. After too many, it opens and fails new calls at once, without waiting. After a short rest it lets one test call through. If that works, it closes and normal calls start again.
Retry with Exponential Backoff
Try a failed call again. Wait longer before each new try.
Retry with backoff means trying a failed call again, and waiting longer each time. A common plan doubles the wait each time: 1 second, then 2, then 4, then 8. Many failures are brief, so a retry often works. Waiting longer each time gives a struggling service room to recover. A little random extra wait, called jitter, stops many clients retrying at the same moment.
In one line
- Circuit Breaker Pattern
- Stop calling a failing service for a while. Then trouble does not spread.
- Retry with Exponential Backoff
- Try a failed call again. Wait longer before each new try.