Designing for failure
In a distributed system, something is always broken: a disk, a node, a network link, a dependency, a deploy. Designing for failure means accepting that, and building so that when a part fails, the damage stays small, users see a degraded service rather than none, and the system recovers without heroics.
The question to ask of every design is not “will this fail?” but “when this fails, what happens, and who notices?”
Know your failure modes
Section titled “Know your failure modes”For each component and dependency, write down how it fails, not just whether:
- Crash: it stops. The easiest to detect.
- Slow: it answers, eventually. The most common and the most harmful, because callers wait and fill up.
- Wrong: it answers quickly with bad data. The hardest to detect.
- Partial: it works for some requests, tenants or regions and not others.
- Correlated: several “independent” parts fail together because they share a zone, a deploy, a certificate, a configuration or a dependency.
A failure mode and effects analysis (opens in a new tab) of your most important user journey is a good first exercise: list each step, how it can fail, the effect on the user, and how you’d know.
Limit the blast radius
Section titled “Limit the blast radius”- Bulkheads. Give each dependency or tenant its own pool of threads, connections or capacity, so one failing dependency can’t exhaust resources the others need.
- Cells and shards. Split users or tenants across independent copies of the system, so a bad deploy or overload affects one cell, not everyone.
- Gradual rollout. Release to a small share of traffic first (canary release), and roll back automatically on errors.
- Independent failure domains. Spread replicas across zones, and check that they really are independent: a shared database, cache or configuration service makes them fail together.
Fail fast and protect yourself
Section titled “Fail fast and protect yourself”- Timeouts on every call, and deadlines passed down the call chain.
- Circuit breakers to stop calling dependencies that are clearly failing.
- Load shedding: when overloaded, reject some requests quickly (lowest priority first) so the rest succeed, rather than serving everyone slowly.
- Backpressure: bounded queues and rate limits, so overload is pushed back to callers instead of building up in memory.
Degrade gracefully
Section titled “Degrade gracefully”Decide in advance, with the product owner, what the system does without each dependency. Write it down per feature:
| Dependency down | Degraded behavior |
|---|---|
| Recommendations | Show best sellers |
| Reviews | Hide the reviews section |
| Delivery estimate | Show “estimate unavailable”, allow checkout |
| Fraud scoring | Hold high-value orders for review, accept low-value ones |
| Payments | Stop checkout clearly; don’t guess |
The last row matters: degrading isn’t always possible, and for money movement or safety-critical actions, a clear failure is often the safe choice.
Static stability
Section titled “Static stability”A system is statically stable if it keeps working when the things that manage it fail. The data plane (serving requests) should keep running with its last known configuration if the control plane (deploying, scaling, configuring) is down. Pre-provision enough capacity to survive the loss of a zone without needing to launch anything new, because the launch system may be failing too. AWS describes this in static stability using Availability Zones (opens in a new tab).
Make recovery boring
Section titled “Make recovery boring”- Idempotent operations (idempotency), so retries and replays are safe.
- Automated, tested rollback for deploys and configuration changes.
- Runbooks for the failures you’ve predicted, and practice using them.
- Restores that are tested, not just backups that are taken.
Prove it
Section titled “Prove it”Designs for failure are hypotheses until tested.
- Game days: simulate a failure in a controlled way, with the team watching, and check the system and the people respond as planned.
- Chaos experiments: inject failures (kill instances, add latency, block a dependency) continuously, in small and controlled doses. The principles of chaos engineering (opens in a new tab) describe how to do this safely: start with a hypothesis about steady state, minimize the blast radius, and be able to stop the experiment at once.
- Load tests to breaking point, so you know how the system fails, not just how fast it is.
Checklist
Section titled “Checklist”- Every remote call has a timeout and a known failure behavior.
- No single zone, instance, certificate or configuration change can take down the whole service.
- Each feature has a written degraded mode, agreed with the product owner.
- Overload results in fast rejections, not slow everything.
- The system keeps serving if the control plane is down.
- Failures have been injected and observed, not just predicted.
In practice
Section titled “In practice”- Failure stories: 24 ways systems fail that weren’t in the design
- Incidents by mechanism: published postmortems grouped by how they failed
- Counterexample: more replicas, higher availability
- Disaster recovery readiness checklist
- High availability and multi-region
Written and edited by Abhinav Taduka, enterprise software architect.
New pages are added regularly. Follow Abhinav on LinkedIn to see them first.