Resilience & Fault Tolerance
Contain partial outages with timeouts, jittered retries, circuit breakers, and load shedding.
In plain words
Resilience patterns stop one failing part from bringing down everything else, the way a fuse protects a house’s wiring.
Think of it like…
Electrical circuit breakers in a house: when one appliance shorts out, the breaker trips instantly to protect the whole house wiring from catching fire.
Where you’ve seen it
If the recommendations service is down, Amazon still shows the product page with a generic list instead of failing the whole page.
Words you’ll hear
- Timeout
- Give up on a call after a set time instead of waiting forever.
- Retry with backoff
- Try again, waiting longer each time, with some randomness (jitter).
- Circuit breaker
- Stop calling a failing service for a while so it can recover.
- Bulkhead
- Separate resource pools so one overloaded part can’t starve others.
Visual diagram
Theory & deep dive
How cascading failures take down entire companies
Imagine your Recommendations service freezes and starts taking 30 seconds instead of 20 ms. If your Product Page service calls it with no timeout (or a 60s timeout) and retries 3 times, all web worker threads quickly get stuck waiting on Recommendations - and soon login, cart, and checkout crash too!
Resilience patterns isolate blasts: Timeouts cap every call, Circuit Breakers stop calling a dead dependency and serve a graceful fallback, Bulkheads keep separate thread pools per dependency, and Load Shedding drops low-priority traffic before the ship sinks.
How it works, step by step
Step 1 of 41. Enforce strict timeouts everywhere
Never make an HTTP/DB/RPC call with an infinite timeout. Propagate end-to-end request deadlines so a caller stops work once the client already timed out.
- Connect Timeout
- 100–500 ms
- RPC Deadline
- Propagated
When to use it & trade-offs
What it is
Resilience patterns stop a slow or failing dependency from cascading and taking down the entire application.
Why it matters: In distributed systems, slow dependencies are worse than fast crashes: hanging threads exhaust pools and cause domino-effect outages across every upstream caller.
When to reach for it
- Wrapping third-party APIs (Stripe, Twilio, OAuth providers) in timeouts + circuit breakers
- Serving stale cached data or generic fallbacks when personalization services degrade
- Priority-based load shedding (protect checkout & login; shed analytics/previews first)
When to avoid or be careful
- Retrying aggressively at 3 nested layers simultaneously (3 × 3 × 3 = 27× traffic amplification!)
- Retrying non-idempotent POST requests without an
Idempotency-Key
Core Fault-Tolerance Mechanisms
429s, brief leader failoversStrengths: Spreads retry attempts smoothly instead of hammering at the exact same millisecond.
Watch out: Retrying non-idempotent writes or retrying through an already overloaded tier worsens outages.
Strengths: Turns 5-second timeout hangs into <1 ms fast-fails with clean fallbacks.
Watch out: Requires careful threshold tuning so brief blips do not false-trip.
Strengths: If the ML recommender hangs, Checkout still completes at 100% speed.
Watch out: Adds separate thread/connection pool sizing and fallback UI states.
Interview signals & numbers to know
When this topic comes up
- cascading failure
- third-party downtime
- retry storm
- graceful degradation
- circuit breaker
Benchmarks & rules of thumb
- Retry amplification (3 layers × 3)
- Up to 27× load
- Circuit breaker error trip
- e.g. >50% over 20 reqs
- Half-open cooldown
- 15–60 seconds
- Load shedding status
- 503 Service Unavailable
Common mistakes & follow-ups
Common interview mistakes
- Retrying
400 Bad Requestor401 Unauthorized(client bugs never heal on retry) - Omitting jitter from exponential backoff (every failed client wakes up at the exact same second)
- Letting a slow optional widget (e.g., “Related items”) share a thread pool with core login/checkout
Likely interviewer follow-ups
- Why is a slow hanging dependency often more dangerous than one that crashes immediately?
- Explain retry amplification across 3 microservice layers and how retry budgets prevent it.
- How do you design graceful degradation for an e-commerce homepage during Black Friday spikes?
Knowledge check
Put it into practice
Design full architectures with AI feedback
Apply Resilience & Fault Tolerance inside real High-Level Design prompts or review Q&A flashcards.