Faults aren't failures: what DDIA taught me about reliability
Notes from DDIA chapter 1: the difference between faults and failures, why redundancy can't save you from bugs, and a real poison-message example from a Kafka-based alarm system.
On this page 7 sections
I'm reading Designing Data-Intensive Applications (DDIA) by Martin Kleppmann, one chapter at a time, and writing down what I learn. This is the first post: reliability. I'll use a real example from my work, a fire alarm monitoring system built on Kafka, and I'll also show where my first answer was wrong.
What "reliable" actually means
A reliable system keeps doing what users expect, even when something goes wrong: a user makes a mistake, load spikes, or a piece of the system breaks.
That last part is the key. Things will break. Reliability isn't about nothing ever going wrong. It's about the system staying useful when something does.
Faults are not failures
This was the most useful distinction in the chapter for me:
- A fault is one component going wrong: a server crashes, a disk dies, a service responds slowly.
- A failure is the system as a whole stopping: users can't get what they came for.
Some teams even cause faults on purpose, killing random servers in production, so they know the system survives them. Netflix's Chaos Monkey is the famous example.
A single Kafka consumer crashes, but another consumer in the same group takes over its partitions and no message is lost. What happened?
Show the answer
Answer: A fault that did not become a failure
One component broke (a fault), but users were never affected, so there was no failure. That's fault tolerance working.
Three kinds of faults
| Kind | Example | Usual defence |
|---|---|---|
| Hardware | A disk dies, a server loses power | Redundancy: replicas, RAID, more machines |
| Software | A bug that crashes every instance on the same input | Testing, isolation, monitoring, letting processes crash and restart |
| Human | A bad config change or a broken deploy | Easy rollbacks, staging, gradual rollouts, good monitoring |
The difference between the first two surprised me:
- Hardware faults are mostly independent. Two disks rarely die in the same second, so adding more machines helps.
- Software faults are correlated. A bug lives in the code, and the code runs everywhere. When it triggers, it can take down every instance at once.
And humans? Studies of large services find that configuration mistakes by operators cause more outages than hardware does.
My example: the poison message
Here's the question I was asked while studying:
You ship a deploy with a bug: every consumer crashes when it reads one specific type of message. What kind of fault is it, why won't more consumers help, and what would stop it from becoming a failure?
My answers:
- Software fault. Correct. (More precisely: a software bug that reached production through a human action, the deploy. Many real outages look exactly like this.)
- More consumers won't help, because the bug crashes all of them. Correct. It's a correlated fault. Ten consumers means ten crashes on the same message.
- Strong monitoring, so we spot it fast, fix it, and add tests. Only half right.
Where I was wrong
Monitoring tells you that something failed. By the time the alert fires, the failure has already happened. In a fire alarm system, minutes of missed alarms is exactly the outcome we can't accept.
Monitoring shortens a failure. It doesn't prevent one. And tests prevent the bug, which is good, but some bugs will always get through. Fault tolerance is about surviving the ones that do.
What actually stops this fault from becoming a failure:
- Handle the poison message. Catch the exception for that one message, move it to a dead-letter topic, and keep consuming. One bad message no longer stops all the good ones.
- Canary deploys. Roll the new version out to one consumer first. If it crashes, the rest are still running the old version.
- Automatic rollback. If the error rate jumps after a deploy, roll back without waiting for a human.
while (!ct.IsCancellationRequested)
{
var result = consumer.Consume(ct);
try
{
await HandleAsync(result.Message.Value);
}
catch (Exception ex)
{
// Don't let one bad message stop every alarm behind it.
await deadLetter.ProduceAsync("alarms.dead-letter",
new Message<string, string> { Key = result.Message.Key, Value = result.Message.Value });
logger.LogError(ex, "Moved message at offset {Offset} to dead-letter", result.Offset);
}
consumer.Commit(result);
}
Deep diveWhy not just retry the message forever?
Because the bug is deterministic: the same message crashes the same code every time. Retrying forever turns one bad message into a stuck partition, and every alarm behind it waits. Retry a few times for transient errors (a timeout, a database blip), then dead-letter it.
Flashcards
QFault
QFailure
QFault-tolerant
QCorrelated fault
QWhy redundancy can't fix a bug
QPoison message
What's next
Next post: scalability. Why "our system is scalable" means nothing on its own, how Twitter's home timeline shaped their architecture, and why you should look at p99 latency instead of the average.
If you're reading DDIA too, I'd love to compare notes.