Part 5 of 9
Reliability and fault tolerance
People expect a reliable app to:
- do what they expected it to do,
- cope with their mistakes or with odd ways of using it,
- perform well enough for the expected load and amount of data,
- keep out people who should not get in, and stop abuse.
In short: it keeps working correctly even when things go wrong.
- A fault is one part going wrong: a disk, a crashed machine, an outside service that is down.
- A failure is the whole system no longer giving users the service it promised, that is, missing its SLO.
- They are the same idea at different levels. For the disk itself, dying is a failure. If your system is just that one disk, the system has failed. If you keep copies on many disks, it is only a fault the system can ride out.
Fault tolerance
- A fault-tolerant system keeps giving the required service despite certain faults.
- A single point of failure is a part whose fault becomes a failure of the whole system.
- Case study example: a machine crashes halfway through delivering a post to followers. Another machine must finish the job without skipping or doubling any timeline entry. This is called exactly-once behavior, covered in a later chapter.
- Every design survives only some faults, of some kinds, up to some count: "up to two disks at once" or "one node out of three". Surviving any number of faults, like every machine dying together, is impossible.
- Fault injection: trigger faults on purpose, such as killing random processes, so the error handling keeps getting exercised. Many serious bugs live in poor error handling.
- Chaos engineering is the practice of running such experiments to build trust that your fault tolerance really works.
- Usually, tolerating faults is better than trying to prevent them. But some faults have no cure, like a security breach where private data has leaked, so those must be prevented. This course mostly deals with faults that can be cured.
Hardware faults
| Part | Rough fault rate |
|---|---|
| Magnetic hard drive | 2-5% fail per year; with 10,000 disks, about one dies a day |
| SSD | 0.5-1% fail per year; small bit errors are fixed automatically, but each drive sees about one uncorrectable error a year, even when new, which is more than hard drives |
| Power supplies, RAID controllers, memory sticks | fail too, but less often than drives |
| CPU | about 1 machine in 1,000 has a core that sometimes gives wrong answers, likely from manufacturing defects; sometimes it crashes, sometimes it is silently wrong |
| RAM | cosmic rays or defects corrupt data; even with error-correcting (ECC) memory, over 1% of machines see an uncorrectable error each year, usually a crash and a module swap |
- Hard drives are getting more reliable, but their failure rate still matters.
- Some patterns of memory access can flip bits in nearby memory with high probability.
- Whole datacenters go dark from power cuts or network mistakes, or are destroyed by fire, flood, or earthquake.
- Rare solar storms can induce currents that damage power grids and undersea cables. This is a disaster if your system cannot survive losing a datacenter.
- A small system can mostly shrug these off if broken parts are easy to replace. At large scale, hardware faults are a normal part of daily operation.