How does the Circuit Breaker pattern differ from the Retry pattern?

The Circuit Breaker and Retry patterns both handle service call failures but take opposite approaches: Retry keeps trying the same request, while Circuit Breaker stops sending requests once a service is clearly failing.

Key Points: • Retry is optimistic — it assumes the failure is transient and will likely succeed if attempted again, usually with a backoff delay between attempts. • Circuit Breaker is protective — it assumes repeated failures mean the service is genuinely unhealthy, so it stops calls entirely to avoid wasting resources and making things worse. • Used together, Retry handles single transient blips while Circuit Breaker prevents Retry itself from hammering a truly down service with repeated attempts. • A circuit breaker tracks failure rate over a rolling window and trips open after a threshold, whereas a retry policy just governs a single call's attempt count. • Circuit Breaker protects the caller from resource exhaustion (blocked threads, exhausted connection pools); Retry protects the overall request from momentary glitches.

Example: If a Payment Service has a five-second outage, Retry alone might succeed on the second attempt for one request, but under sustained load a Circuit Breaker is what actually protects the system by tripping open after enough failures and stopping the flood of retried requests until the service recovers.

Interview Tip: A concise interview answer is:

"Retry re-attempts a failed call, assuming the problem is temporary, while Circuit Breaker stops sending calls altogether once failures cross a threshold, assuming the service is genuinely unhealthy. In practice they're complementary — I wrap retries inside a circuit breaker so isolated blips get retried, but a real outage doesn't turn into a flood of repeated retry attempts."