Kayavak / The Backend / BE·52 Resilience / Deeper
Deeper · The Backend
Resilience
The questions the chapter doesn't stop for: why this exists, the model to keep in your head, what changes when an assumption does, how sure we are of each claim, and what's still open. Read it after the chapter; back to the chapter.
Why does this exist?
When a service depends on others, their failures become its failures, and slow failures are the worst: threads pile up waiting until the whole service stops. Michael Nygard's Release It! (2007) collected the patterns that stop this (timeouts, circuit breakers, bulkheads), named after electrical and ship design. Netflix, moving to the cloud, built them into its Hystrix library (2012) and started deliberately killing its own servers with Chaos Monkey (2011) to prove the system survived. In 2015 Marc Brooker at AWS published measurements showing that retries with jitter (random delays) prevent clients from retrying in synchronised waves.
The common lesson from large outages is that recovery mechanisms often cause the next failure: retries multiply load on a struggling service, timeouts set longer than the caller's own deadline waste work, and every server restarting at once overwhelms what they depend on.
The mental model
Try it yourself first: write your own model in the Mental Model Explorer, then compare.
Every call to another system can fail, be slow, or succeed without you knowing. Bound how long you wait, how often you retry and how much of your capacity any one dependency can consume, and shed load before you collapse.
| Question | Answer |
|---|---|
| What is it? | Designing services that keep working, partly, when their dependencies or their own load go wrong |
| Problem it solves | Partial failures turning into total ones (cascading failure) |
| Parts | Timeouts and deadlines, retries with backoff and jitter, circuit breakers, bulkheads, rate limiting, load shedding, fallbacks |
| How it works | Each pattern caps a different resource: waiting time, repeated load, calls to a failing dependency, threads per dependency, incoming work |
| Assumptions | Retried operations are idempotent; errors are transient |
| When they change | Retrying a non-idempotent or permanent error duplicates effects or just adds load |
| Where it fails | Retry storms, timeouts longer than the caller's deadline, all clients recovering at once |
| Related ideas | Idempotency (ch45, ch51); queues and Little's law (ch41); SRE and incident response (Observability and SRE) |
What if?
What if every layer of a call chain retried three times?
Reason it through, then open
See the derivation below: a failure at the bottom of a three-layer chain receives up to 27 attempts for each original request, exactly when it's least able to cope. Retry at one layer (usually closest to the user), cap retries with a budget, and add jitter.
What if a dependency becomes slow instead of failing?
Reason it through, then open
Errors return quickly; slow calls hold threads, connections and memory while they wait. Without timeouts, Little's law (ch41) says in-flight requests grow with the delay until pools run dry and your service stops answering anything, including requests that don't need the slow dependency. Timeouts, bulkheads (separate pools per dependency) and circuit breakers keep one slow dependency from taking everything down.
Where the boundary is
| Aspect | Circuit breaker | Retry |
|---|---|---|
| Responds to failure by | Stopping calls for a while | Trying again |
| Helps | The failing dependency recover; callers fail fast | Transient blips succeed |
| Hurts when | Thresholds are wrong and it trips on noise | The dependency is overloaded or the error is permanent |
| Together | Retries inside a breaker: the breaker caps how much retrying can happen |
Derive it
Retry amplification.
- A request passes through three services, A → B → C, and each layer makes up to 3 attempts on failure.
- If C fails every time, B makes 3 calls to C for each call it receives.
- A makes 3 calls to B for each request, and each of those makes 3 calls to C: 3 × 3 = 9 calls to C.
- If the client in front of A also retries 3 times, C receives 3 × 3 × 3 = 27 calls per user action.
- In general, with r attempts at each of k layers, the bottom sees rᵏ attempts. Load on the failing service multiplies exactly when it is failing, which is why retries belong at one layer and need a budget.
How sure are we?
| Claim | How it's known | Where from |
|---|---|---|
| Retries at k layers with r attempts give rᵏ calls | Theorem | The arithmetic above |
| Jitter spreads out synchronised retries | Measured | Brooker, Exponential Backoff and Jitter, AWS Architecture Blog, 2015 |
| Circuit breakers and bulkheads were popularised by Release It! | Historical | Nygard, 2007 |
| Slow dependencies are worse than failed ones | Model | Widely observed in incident reports; follows from Little's law |
Still open
Adaptive approaches (concurrency limits that adjust from measured latency, retry budgets shared across a fleet) are replacing fixed thresholds, and tuning them is still more craft than science.
What would change your mind? If your dependencies never failed partially (only cleanly and briefly), simple retries would suffice. Production incident histories rarely look like that.
Recall
How many calls does a failing bottom service get if each of k layers retries r times?
rᵏ per original request.
Why add jitter to backoff?
To stop many clients retrying in synchronised waves.
Why are slow dependencies worse than failing ones?
Slow calls hold threads and connections, so in-flight work grows until pools are exhausted.
What does a bulkhead do?
Gives each dependency its own limited pool, so one can't consume all capacity.
When shouldn't you retry?
For non-idempotent operations and permanent errors, or when the dependency is overloaded.
Reflect
Be honest with yourself; this stays in your browser. Anything you can't tick yet is what to revisit.