A downstream service is failing and timing out. Which pattern stops your service from hammering it and failing slowly?
Options
- Circuit breaker (Correct option)
- Singleton
- Saga
- Sharding
Answer
Circuit breaker
Why
Like an electrical breaker: after several failures in a row, the circuit 'opens' and calls to that service fail immediately (or return a fallback) instead of waiting for timeouts.
This protects your own threads and gives the broken service time to recover. After a pause, the breaker lets a test request through ('half-open'); if it works, it closes again.
Combine with timeouts and retries with exponential backoff.
Remember
Circuit breaker = stop calling a failing service for a while.