Eli Brody
← Back to blog

Designing for Failure

· 8 min read
Systems Architecture SRE Reliability

Every system fails. Whether a failure stays a minor incident or becomes a catastrophic outage depends on whether you designed for it.

Most teams build on an unstated assumption: if we write good code and configure things correctly, the system will work. That's technically true and practically useless, because conditions are rarely ideal. What matters is whether the system degrades gracefully when they aren't.

Two Kinds of Failure

Some failures you anticipated: a database connection times out, a service returns an error, a disk fills up. You've written handlers for these, and your monitoring alerts cover them.

Others you didn't anticipate: a leap second causes a time calculation bug, a certificate expires over a holiday weekend, a configuration change in one service cascades into a system-wide outage. These are the failures that wake people up at 3 AM.

You can't predict every possible failure, but you can build systems that stay controllable when the unexpected happens.

Principles of Failure-Aware Design

1. Explicit Failure Modes

Every component should have documented failure modes. "It might crash" isn't enough. Be specific: what happens when this service is unavailable, when it's slow, when it returns corrupted data?

Document these modes and their expected impact. A database failure might be recoverable in seconds with a replica failover. A cache failure might cause temporary performance degradation. An authentication service failure might block all user access. These differ in severity, and each needs its own response.

2. Bounded Blast Radius

When something fails, the failure should be contained. That takes:

A failure in your recommendation engine shouldn't take down your checkout flow. A spike in traffic from one customer shouldn't degrade service for everyone else.

3. Graceful Degradation

Systems should have defined states between "fully operational" and "completely down." When your personalization service fails, show generic recommendations. When your analytics pipeline backs up, queue events and don't block user actions. When your search index is stale, serve cached results with a freshness indicator.

Decide these degraded behaviors in advance, so nobody has to improvise them during an incident. Every critical dependency should have a fallback path, even if the fallback is "return an error message that tells the user exactly what's happening."

4. Observable Failure States

You can't manage what you can't see. Every failure mode should be observable:

Collecting data is the easy part. The test of observability is whether you can answer questions you didn't know you'd need to ask.

The Testing Gap

Most testing verifies that systems work correctly. Very little verifies that they fail correctly.

Chaos engineering addresses this by introducing failures on purpose: killing processes, injecting latency, corrupting network packets. It's only valuable if you know what correct failure behavior looks like. Before you break things, define what "graceful degradation" means for each failure scenario.

Start small. Pick one critical path through your system and map every external dependency. For each one, ask what happens if it fails, whether that's acceptable, and what the mitigation is if it isn't.

Recovery as a Feature

Recovery shouldn't require heroics. If recovering from a failure depends on someone remembering the right sequence of manual steps, your system is fragile, however rarely it fails.

Design recovery into the system:

The best incident response happens automatically, and the humans are told about it afterward.

Starting Point

If you're not sure where to begin, I'd start with this:

  1. List your system's critical paths (the user flows that must work)
  2. For each critical path, identify every dependency
  3. For each dependency, document what happens if it fails
  4. For each unacceptable failure mode, design a mitigation
  5. Test the mitigations regularly

You'll need to repeat the exercise. Systems evolve, dependencies change, and new failure modes appear, so designing for failure never has an end date.

The best time to think about failure is before it happens. The second best time is now.

Systems don't fail because engineers are careless. They fail because nobody treated failure as a first-class concern. The teams that build reliable systems still have failures. They've made them boring.

Comments