TechCoder.io / System Design

Circuit Breaker, Retries & Backoff

Master the circuit breaker pattern (Closed, Open, Half-Open states), exponential backoff with jitter, retry budgets, bulkhead isolation, and timeout design to prevent cascading failures in distributed systems.

By TechCoder TeamLast updated: 2026-10-17
In a Nutshell

Master the circuit breaker pattern (Closed, Open, Half-Open states), exponential backoff with jitter, retry budgets, bulkhead isolation, and timeout design to prevent cascading failures in distributed systems. This hands-on tutorial focuses on practical implementation of circuit breaker, retries & backoff concepts.

Circuit Breaker, Retries & Backoff

In distributed systems, every service call can fail. A database might be slow. An external API might time out. A downstream microservice might crash. Without proper failure handling, these problems cascade — one slow service causes all its callers to hang, which causes their callers to hang, until the entire system falls apart.

[!IMPORTANT] A naive retry loop can turn a temporary outage into a permanent one. If 10,000 clients all retry every second when a service is down, they generate 10,000 req/sec of load — preventing the service from ever recovering. Retries must be implemented with exponential backoff and jitter.

Retry with Exponential Backoff & Jitter

PYTHON PLAYGROUND
⏳ Loading editor…

The Circuit Breaker Pattern

The Circuit Breaker prevents making calls to a failing service — saving resources and giving the failing service time to recover:

PYTHON PLAYGROUND
⏳ Loading editor…

Quiz

Quiz

Question 1 of 2

A payment service starts failing. Your upstream service retries immediately. What happens if 10,000 clients all retry simultaneously every 1 second?

The payment service recovers quickly because it receives more requests
The retry storm (thundering herd) prevents the service from recovering — 10,000 req/sec of retries overwhelm it further
The retries are queued and processed in order

Key Takeaways

✅ Never retry with a fixed interval — use exponential backoff + full jitter to prevent thundering herds.
✅ Circuit Breaker states: CLOSED (normal) → OPEN (failing fast) → HALF_OPEN (testing) → CLOSED (recovered).
✅ Always provide a fallback — serve cached data, a degraded response, or a user-friendly error message.
✅ Timeouts are mandatory — a request without a timeout can hang forever and exhaust thread pools.
✅ Bulkhead pattern — isolate resource pools (thread pools, connection pools) per downstream service to prevent one failure from consuming all resources.

Circuit Breaker vs Retry vs Timeout — When to Use What

StrategyWhat it DoesWhen to UseRisk
TimeoutAbort if no response in N msAlways — never wait foreverToo short = false failures
RetryRetry failed requests N timesTransient failures (network blip)Amplifies load on struggling service
Exponential BackoffIncrease wait between retriesAll retriesSlow recovery if base too high
JitterRandomize retry timingMultiple clients retrying same serviceAdds complexity
Circuit BreakerStop calling failing service entirelyService consistently failingState management overhead
BulkheadIsolate resources per downstreamProtecting against cascading failureOver-provisioning

Official Resources

What's Next?

You've secured your system against failures — now you need to see when things go wrong before your users do.
Next: Health Checks & Observability — The three pillars of observability (metrics, logs, traces) and how to monitor your system.