Failure models
medium 30 minA failure model is a list of the ways a machine or message may go wrong that your design promises to survive.
Video lesson · Chapter 1 of 5
Silence is evidence, not a diagnosis
Stop, stall or lie in 75 seconds
1:15Reel coming soon
Theory
Read or listen first. About 2 min.
What it is
When many machines work together, some of them fail while the rest go on. A failure model describes how a part may fail: it may stop for good, stop and come back, lose messages, answer too late, or answer wrongly.
The model is a promise about your assumptions. A design that survives machines that stop may still break when a machine sends wrong data. So the first question about any reliable system is: reliable against what?
Why it exists
No design survives everything, and each extra kind of failure costs something. To go on after one machine stops, three machines with majority voting are enough. To go on while one machine lies, you need four and more rounds of messages.
The model also decides how you find out. A stopped machine and a slow one look the same from outside: both are silent. Every detector is a guess with a time limit, and it can be wrong in both directions.
A short history
1982
Lamport, Shostak and Pease publish "The Byzantine Generals Problem" and give arbitrary failures their name.
1985
Fischer, Lynch and Paterson show that in an asynchronous system no deterministic protocol can guarantee that consensus finishes if even one process may fail. The result is called FLP.
1996
Chandra and Toueg publish unreliable failure detectors: how much guessing is enough to reach consensus.
1999
Castro and Liskov present Practical Byzantine Fault Tolerance, PBFT, at OSDI.
2018
The HotStuff paper describes a leader-based Byzantine protocol, presented for blockchains.
Words to know
- Fault
- Something is wrong in one part, such as a broken disk.
- Failure
- The part, or the system, no longer does what it promised.
- Crash-stop
- A process halts and never comes back.
- Crash-recovery
- A process halts and may return with what it stored on disk.
- Omission
- A message is not sent or not received.
- Timing failure
- The answer is right but too late.
- Byzantine
- Any behaviour at all, including lies.
- Failure detector
- A part that guesses, from silence, who has failed.
- Quorum
- How many nodes must agree before the system acts.
How it works
Step through the idea, or press Play.
List what may go wrong. Stop, return, lose messages, be slow, lie
Understand it
Start here
The helper robots
A workshop has three helper robots that pass boxes and messages along. On a good day nobody notices them. On a bad day each robot has its own way of going wrong, and each needs a different answer.
From outside, the stopped robot, the lost note and the slow robot look alike: silence.
A game of passing notes shows the same classes: a friend goes home (crash), a note gets lost (omission), a friend is too slow (timing), or a friend changes the note (Byzantine).
The ladder
From simple to hard
| Model | What happens | Examples | Answer |
|---|---|---|---|
| Crash-stop | Halts, never returns | Dead hardware, a killed process | Replicas, leader election |
| Crash-recovery | Halts, may return with its disk | Restart, out-of-memory kill, rolling update | Write-ahead log, checkpoints |
| Omission | Some messages lost | Packet loss, full queue, firewall rule | Acknowledge, retry, remove duplicates |
| Timing | Right, but too late | Garbage collection pause, busy CPU, slow disk | Timeouts, circuit breakers |
| Byzantine | Anything, even lies | Corrupt memory, a bug, a taken-over node | Votes with 3f + 1 nodes, signatures |
Each class contains the simpler ones
Crash
Stop, and stop then return
Crash-stop is the kindest failure: a process works correctly until it halts. Crash-recovery is closer to life. The process comes back, memory is gone, and the disk holds what was flushed. It may also believe it is still the leader.
Handling a crash
- 1
Heartbeats
Each node sends a small message at a fixed pace.
- 2
Timeout
Too long without one: suspect the node.
- 3
Election
The rest agree on a new leader with a higher term number.
- 4
Recovery
The returning node replays its log, sees the higher term and follows.
A leader stops
Recovery
Write-ahead log
Before changing anything, write down what you are about to do and force it to disk. After a crash, replay the log. The order matters: log, fsync, then confirm. A log that was never forced to disk can vanish with the power, together with a write you already confirmed.
disk = [] # survives a crashmemory = {} # does notdef put(key, value): disk.append((key, value)) # 1. log first (and fsync) memory[key] = value # 2. then change return "ok" # 3. then confirmput("stock", 5)put("stock", 4)memory = {} # crashfor key, value in disk: # replay memory[key] = valueprint(memory)Messages
Omission
Send omission
- A buffer overflows before the network
- A firewall blocks traffic out
- A bug skips the send
Receive omission
- The packet is lost on the way
- The receive buffer is full
- The queue overflows
Acknowledge every message, retry with growing pauses and jitter, and give each message a number so that the receiver can drop duplicates. Retrying has a trap: when the answer is lost, the work was done. Only idempotent work may be repeated blindly. More in retries.
The answer is lost
Chance that all tries are lost
Slow
Timing failures
A slow node is often worse than a dead one. It still answers health checks, still receives work, and holds the threads of everybody who waits for it. Set timeouts, stop calling it for a while with a circuit breaker, and compare nodes with each other: the one far from the rest is the sick one.
Lies
Byzantine failures
Different values to different nodes
A says the box is red to one and blue to another.
Lying about what it received
It claims a vote that never came.
Working together
Several faulty nodes tell the same lie.
Being slow on purpose
It answers just before each timeout.
The cause need not be an attacker. A bad memory chip, a bug or a wrong build can make a node say different things to different peers. Inside one company most systems accept that risk and use checksums instead of full Byzantine agreement. Between organisations that do not trust each other, such as in a blockchain, it is the normal model.
Why 3f + 1 nodes
Nodes needed to survive f failures
| f | Crash, data still readable | Crash, majority voting | Byzantine voting |
|---|---|---|---|
| 1 | 2 | 3 | 4 |
| 2 | 3 | 5 | 7 |
| 3 | 4 | 7 | 10 |
One liar among four
PBFT, HotStuff and Tendermint, now developed as CometBFT, reach agreement with such quorums, several rounds and signatures. A signature proves who sent a message and stops others from changing it. It does not stop a node from signing two different messages, so the votes are still needed.
Detection
Guessing from silence
| Method | How | Good | Weak |
|---|---|---|---|
| Heartbeat with timeout | A node sends every second; silent for 5 s: suspect; 10 s: failed | Simple | One fixed limit for all networks |
| Phi accrual | Turns the time since the last heartbeat into a level of suspicion | Adapts to the network; callers choose the limit | Needs history to learn from |
| SWIM | Probe a random member; if silent, ask others to probe it | Constant load for each member; fewer false alarms | News spreads by gossip, so not at once |
An indirect probe
Real settings
| System | Setting | Default in its documents |
|---|---|---|
| etcd 3.5 | Heartbeat interval | 100 ms |
| etcd 3.5 | Election timeout | 1,000 ms |
| Kubernetes | Lease renewed by the kubelet | every 10 s |
| Kubernetes | Silence before a node is unknown | 50 s |
| Kubernetes | Wait before evicting its pods | 5 minutes |
Choosing the timeout
Silence: what now?
Do it well
Working rules
Do
- State the model and how many failures at once
- Heartbeats with limits that fit the network
- A log that is forced to disk
- Retries with backoff, jitter and a limit
- Signatures where nodes are not trusted
- Break things on purpose, regularly
Do not
- Assume that nodes are always reachable
- Set limits so tight that healthy nodes are killed
- Retry for ever
- Trust unverified messages across a trust border
- Ignore half-broken nodes
One line to remember: design for the failures you expect, and watch for the ones you do not. How to keep serving while parts fail is the subject of resilience.
Summary
The whole topic in one minute.
Failures form a ladder: crash-stop, crash-recovery, omission, timing, Byzantine. Higher steps include more bad behaviour and cost more to survive: 2f + 1 nodes for f crashes with majority voting, 3f + 1 for f liars.
Detection is guessing from silence. Heartbeats with timeouts are simple, accrual detectors give a level of suspicion, and SWIM spreads the work over the group. A slow node cannot be told from a dead one, so make a wrong guess harmless with fencing, idempotent work and retries with limits.
- A failure model says what your design survives.
- Crash-stop, crash-recovery, omission, timing, Byzantine: each is harder.
- 2f + 1 nodes for f crashes with voting, 3f + 1 for f liars.
- Slow and dead look the same; every detector guesses.
- Log, force to disk, then confirm.
- Make wrong guesses harmless with terms, fencing and idempotent work.