Partial failure and the fallacies of distributed computing
Why a call over the network has a third outcome besides success and failure, which failures a distributed design must expect, why a timeout cannot tell a slow node from a dead one, how gray failures hide from health checks, and where the eight fallacies of distributed computing show up in real designs.
Contentsand lesson path
On this page
- Why it matters
- What can go wrong between machines
- Why a timeout cannot tell slow from dead
- Gray failure: healthy to the checker, broken to users
- The eight fallacies, and where they bite
- How much of this to design for
- Check your understanding
- Apply it
- Review prompt
Lessons of Distributed Systems Fundamentals
- Partial failure and the fallacies of distributed computing Concept · 20 min
- Time, clocks and ordering Concept · 20 min
- Consistency models from linearizable to eventual Concept · 25 min
- CAP and PACELC applied to real databases Worked example · 20 min
- Quorums, Raft and leader leases, step by step Lab · 25 min
- Distributed reasoning check Knowledge check · 8 questions
What you will learn
- Describe distributed failure modes (crashes, partitions, message loss and reordering, clock skew, gray failures) and their effect on a design.
01. Why it matters
Inside one program, a function call has two outcomes: it returns, perhaps with an error, or the whole process stops. Move that function to another machine and call it over the network, and a third outcome appears: you wait, and no answer comes. You cannot tell whether the other machine got the request, did the work, or is still doing it.
Suppose a ticketing service calls a seat-reservation service with a 200 ms timeout. Most calls answer in 30 ms, but now and then nothing comes back. Should it tell the customer the seat is theirs, try again, or give up? Each choice is wrong in some situation, and the situation is exactly what the caller cannot see.
A distributed system is a set of programs on several machines that cooperate by sending messages. Its defining problem is partial failure: some parts fail while others keep working, and the working parts often cannot tell what failed. This lesson names the failures to expect, shows why a timeout cannot settle them, and connects them to the eight fallacies of distributed computing.
02. What can go wrong between machines
The usual first approach treats a remote call like a local one and lets the client library hide the network. On a quiet local network that works more often than critics admit. The trouble comes with scale: at millions of calls a day, a one-in-a-million event happens daily and leaves the system in a state the code never planned for. Each failure mode breaks a different assumption:
- Crash-stop: a process halts and never returns. Easy to reason about, rarely the whole story.
- Crash-recovery: a process halts and restarts, keeping what it saved to disk and losing what it held only in memory, including anything it acknowledged before saving.
- Omission: a message is lost, for example by a full queue or a broken link.
- Delay and reordering: a message arrives late, or after one sent later. TCP keeps order within one connection only; two connections or a retry can reorder messages.
- Duplication: the same message arrives twice, usually because a sender retried.
- Network partition: some nodes cannot reach others although all are running. The split need not be clean: A may reach B and B reach C while A cannot reach C.
- Clock skew: clocks on different machines disagree (lesson 2).
- Gray failure: a component is broken for its users but looks healthy to its monitor.
When order matters, put it in the data rather than trusting the network: if a producer numbers each update to a key, every replica can ignore an update older than the one it already applied, whatever order messages arrive in.
This skill assumes nodes are honest but unreliable. Byzantine failure, where nodes send wrong or conflicting data, needs far more expensive protocols.
03. Why a timeout cannot tell slow from dead
This small model sends reserve seat 14C once for each of six things that can happen to a call, and prints what the caller sees next to what the server did. It needs Python 3.10 or newer.
"""Six things that can happen to one remote call (teaching model).
The caller sends "reserve seat 14C" and waits at most TIMEOUT_MS for a reply.
"""
TIMEOUT_MS = 200
# case: (request arrives, server does the work, handler time ms, reply sent)
CASES = {
"all fine": (True, True, 30, True),
"request lost": (False, False, 0, False),
"server crashed before work": (True, False, 0, False),
"server crashed after work": (True, True, 30, False),
"server slow (GC pause)": (True, True, 450, True),
"reply lost": (True, True, 30, False),
}
def call(arrives: bool, works: bool, handler_ms: int, replies: bool):
seats_reserved = 1 if arrives and works else 0
if replies and handler_ms <= TIMEOUT_MS:
return f"OK after {handler_ms} ms", seats_reserved
return f"no reply in {TIMEOUT_MS} ms", seats_reserved
print(f"{'what really happened':28} {'what the caller saw':20} seats reserved")
for name, case in CASES.items():
seen, seats = call(*case)
print(f"{name:28} {seen:20} {seats}")what really happened what the caller saw seats reserved
all fine OK after 30 ms 1
request lost no reply in 200 ms 0
server crashed before work no reply in 200 ms 0
server crashed after work no reply in 200 ms 1
server slow (GC pause) no reply in 200 ms 1
reply lost no reply in 200 ms 1Five situations produce the same observation: in two no seat was reserved, in three it was and the caller does not know. In the asynchronous network model, which describes real networks well, there is no upper bound on how long a message or a computation may take, so no amount of waiting proves that an answer will never come.
Two consequences follow. First, a timed-out call has an unknown outcome, not a failed one: make the retry safe with an idempotency key, as in Idempotency keys for safe retries, or ask the server later. Second, every failure detector, the part of a system that declares a node dead so another can take over, is making a guess.
The next model shows how the guess depends on the timeout: a healthy node answers 10,000 heartbeats, and about 2 replies in 100 hit a pause such as garbage collection. The numbers are an invented, seeded scenario, not measurements.
"""How a timeout-based failure detector trades false alarms for detection speed.
A healthy node answers 10,000 heartbeats. Most replies take 5-40 ms, but about
2 in 100 hit a pause (garbage collection, a slow disk flush) of 150-900 ms.
Every number here is a made-up teaching scenario, generated from a fixed seed.
"""
import random
rng = random.Random(7)
HEARTBEATS = 10_000
INTERVAL_MS = 100 # one heartbeat every 100 ms
def reply_ms() -> float:
base = 5 + 35 * rng.random() ** 3
if rng.random() < 0.02:
return base + 150 + 750 * rng.random()
return base
replies = [reply_ms() for _ in range(HEARTBEATS)]
print(f"slowest healthy reply: {max(replies):.0f} ms")
HEADER = ("timeout", "false alarms", "per hour", "crash noticed after")
print(f"{HEADER[0]:>8} {HEADER[1]:>13} {HEADER[2]:>9} {HEADER[3]:>20}")
for timeout in (100, 250, 500, 1000):
false_alarms = sum(1 for r in replies if r > timeout)
per_hour = false_alarms * 3600 * 1000 / (HEARTBEATS * INTERVAL_MS)
worst_detect = INTERVAL_MS + timeout # crash just after a successful reply
print(f"{timeout:>6} ms {false_alarms:>13} {per_hour:>9.0f} {worst_detect:>17} ms")slowest healthy reply: 912 ms
timeout false alarms per hour crash noticed after
100 ms 199 716 200 ms
250 ms 181 652 350 ms
500 ms 109 392 600 ms
1000 ms 0 0 1100 msA 100 ms timeout notices a crash within 200 ms but raises about 700 false alarms an hour here. If each alarm triggers a failover, work moves away from nodes that were only paused, and a leader that wakes up may briefly act next to its replacement (lesson 5 shows how fencing tokens contain that). A 1,000 ms timeout raised no false alarms in this sample, but a crash goes unnoticed for up to 1.1 s, and some day a longer pause will come anyway.
There is no correct value, only a choice between the cost of a false alarm and the cost of waiting. Per-try retry timeouts are covered in Timeouts, retries, backoff and jitter; a timeout that triggers failover usually deserves a longer value, because a wrong failover costs more than a wasted retry.
04. Gray failure: healthy to the checker, broken to users
In 2017 Peng Huang and colleagues from Microsoft Research, Microsoft Azure and Johns Hopkins University described gray failure, drawing on incidents in cloud systems. Its defining feature is differential observability: at least one user of a component sees it as unhealthy, while the part of the system responsible for detecting failures sees it as healthy.
Imagine a storage node whose heartbeat thread answers in a millisecond while its request path waits behind a failing disk. The cluster manager sees a healthy node and keeps sending traffic, while one write in four takes several seconds. A shorter heartbeat timeout changes nothing, because heartbeats are not slow. The node has not crashed and is not partitioned; it is broken in a way the detector does not measure.
The remedy is to observe what users observe: latency and error rates measured by callers, health checks that exercise the real request path (for example a small write to the same disk), and comparison of each node with its peers so that outliers stand out. The paper notes that gray failures tend to evolve: absorbed minor faults, then a degraded state users notice but the detector does not, and sometimes a complete failure, the first moment the detector sees anything.
05. The eight fallacies, and where they bite
In 1994 Peter Deutsch, then at Sun Microsystems, listed seven assumptions that almost everyone makes when building a first distributed application, and that all prove false in the long run; James Gosling, also at Sun, added the eighth in 1997. Here is the list as Gosling published it, with a typical way each one bites:
- The network is reliable. Messages are lost, so every call needs a timeout and a plan for the unknown outcome.
- Latency is zero. 30 sequential calls cost 15 ms at 0.5 ms each, and 1.2 s at 40 ms each across regions.
- Bandwidth is infinite. A 2 GB export needs at least 160 s on a 100 Mbit/s link, competing with live traffic.
- The network is secure. Internal traffic can be read or forged, so services authenticate each other and encrypt.
- Topology doesn't change. Hosts are replaced and addresses move; discover services instead of hard-coding addresses.
- There is one administrator. Other teams change firewalls, DNS and versions on their own schedules.
- Transport cost is zero. Serialising costs CPU, and traffic between zones or to the internet costs money.
- The network is homogeneous. Hardware, protocols and versions differ, so plan for mixed versions in every rollout.
The fallacies are a checklist, not a theory. In a design review, go through each remote call and ask which of the eight it silently assumes.
06. How much of this to design for
Designing for every failure costs code, test effort and often a slower normal path. A simpler model is fine when being wrong is cheap and visible: a report that can be rerun or a cache that can be rebuilt may treat a timeout as a failure and start again.
It is not fine when the operation moves money, reserves something scarce, or decides who is in charge. There an unknown outcome becomes a double booking, and a wrong failover becomes two nodes that both believe they lead. The rest of this skill covers those cases: ordering events without trusting clocks (lesson 2), stating what a read can return (lessons 3 and 4), and making machines agree (lesson 5).
07. Check your understanding
08. Apply it
Start the guarantee sheet this skill builds up. Pick three data stores, for example PostgreSQL with replicas, Cassandra and etcd, and list the calls your service makes to each. For every call, write which rows of the timeout_ambiguity.py table a timeout could hide and what your code does next: retry with an idempotency key, check later, or report failure. Name the fallacy each call is most exposed to, and the detector and timeout that decide when the store is "down".
09. Review prompt
Without looking back:
- Explain partial failure in two sentences, using a remote call as the example.
- Name six failure modes and the assumption each one breaks.
- Why can no timeout tell slow from dead, and what follows for retries and failover?
- What is differential observability, and how do you detect a gray failure?
- List the eight fallacies with one design consequence each.
References
- The Eight Fallacies of Distributed Computing (Peter Deutsch, on James Gosling's site)
- Fallacies of Distributed Computing Explained (Arnon Rotem-Gal-Oz)
- Gray Failure: The Achilles' Heel of Cloud-Scale Systems (Huang et al., HotOS 2017)
- Distributed Systems lecture notes, sections 2-3 (Martin Kleppmann, University of Cambridge)
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.