CMD Guide
HomeSystem Design

Quorum

Step 24 in the System Design path · 3 concepts · 0 problems

0 / 3 complete

📘 Learn Quorum from zero

What it is. A quorum is the minimum number of replica votes an operation must collect to count as done. In a leaderless store that copies each datum onto N nodes, you require a write to be acknowledged by W nodes and a read to gather R nodes. Choosing W and R so their sets are forced to overlap (W + R > N) lets the system stay available during failures while bounding how stale a read can be.

The problem it solves. If a write must wait for all N copies, one slow or down node stalls every write. If you write to just one and read from just one, a reader can easily hit a stale copy. Quorums let you dial the overlap so reads still observe recent writes without demanding unanimity.

Analogy. Five friends share a fact that changes. Rule: to update it you must personally tell at least 3 of them (W=3); to look it up you must ask at least 3 and take the newest answer (R=3). Any group of 3 and any other group of 3 out of 5 must share at least one person (3+3=6 > 5), so whoever you ask includes someone who heard the latest update.

Worked example. N=3 replicas A, B, C; W=2, R=2 (W+R=4>3). You write x=10 (version 5); it lands on A and B and acks. C was briefly down and still holds x=9 (version 4). Later you read with R=2 and ask B and C, getting {v5:10, v4:9}. The overlap guarantees at least one node in any 2-node read set has v5 — here, B. You compare versions, return 10, and read-repair pushes v5 to C. Correct, despite C being stale.

Key insight: W + R > N forces every read set to share a node with every write set, so a read observes the latest completed write — but only versioning lets you recognize it, and only consensus gives true ordering.

✨ Added by the guide to build intuition — not from the source course.

Lessons in this topic

🎯 Guided practice

  1. Easy — Tune the knobs. A system has N=5 replicas. The product wants reads to never be stale (bounded by the quorum overlap) but writes are far more frequent than reads, so writes should be cheap. Choose W and R.

    Reasoning: The overlap condition is W + R > N, i.e. W + R ≥ 6. To make writes cheap, minimize W. The smallest valid W is W=1, which forces R ≥ 5, so R=5. Answer: W=1, R=5 (fast writes, full-replica reads). If reads were the hot path instead, flip to W=5, R=1. The pattern: push the cost onto the rarer operation while preserving the overlap inequality. Caveat worth voicing: with W=1 a write that acks from one node, then loses that node before it replicates, is lost — so very low W trades durability for write latency.

  2. Medium — Failure tolerance under a majority quorum. N=5, balanced majority W=R=3 (W+R=6>5). (a) How many node failures can writes tolerate? (b) Two clients concurrently write x=A to nodes {1,2,3} and x=B to nodes {3,4,5} — both reach quorum. What happens, and how do you resolve it?

    Reasoning (a): A write needs W=3 reachable replicas, so it survives up to N − W = 2 failures; reads likewise tolerate N − R = 2. Majority quorum (⌊N/2⌋+1) maximizes failure tolerance while keeping W+R>N, which is why it is the standard default and the size consensus protocols require to commit.

    Reasoning (b): Both writes succeed because each reached 3 nodes — quorum bounds staleness, it does not serialize or prevent conflicting concurrent writes. Node 3 receives both, with no happens-before relation between them. The fix lives at the versioning layer, not the quorum layer: attach vector clocks (the approach Amazon's Dynamo paper introduced; covered in DDIA ch. 5). A later read sees A and B as causally concurrent (neither dominates), so the system must resolve the conflict — either last-write-wins by timestamp (lossy: silently discards one update) or by returning both siblings for application-level merge (e.g. unioning two shopping carts). The lesson: quorum guarantees you'll see the latest completed writes; versioning is what lets you order or merge them.

✨ Added by the guide — work these before the full problem set.

🧠 Review & recall

Active recall is what moves a topic into long-term memory. Flip each card before revealing, then test yourself — your results are saved on this device.

Flashcard
What is a quorum in a distributed system?
tap to reveal →
A quorum is the minimum number of servers (replica votes) on which a distributed operation must succeed before the operation's overall success can be declared. It enforces the consistency needed for distributed operations across replicas.
💡 Quorum = the minimum 'yes' votes needed to commit.
Flashcard
What value should you choose for a quorum, and how does cluster size relate to fault tolerance?
tap to reveal →
A quorum should be more than half the nodes: (N/2)+1. A 5-node cluster needs 3 online (tolerates 2 failures); a 4-node cluster also needs 3 (tolerates only 1). Because the larger odd cluster tolerates more failures for the same quorum size, an odd number of nodes is recommended.
💡 Majority = floor(N/2)+1; odd N gives you more failure budget.
Flashcard
State the quorum protocol inequality W + R > N and what each symbol means.
tap to reveal →
With N = total replica nodes, W = minimum write nodes, and R = minimum read nodes, if W + R > N then every read sees at least one copy of the latest value written, because the read set and any write set are forced to overlap.
💡 Overlap rule: W + R > N means read and write sets must share a node.
Flashcard
For N=3, what do the configs (W=2,R=2), (W=1,R=3), and (W=3,R=1) give you?
tap to reveal →
(N=3,W=2,R=2) is a common balanced config for strong consistency. (W=1,R=3) gives fast writes but slow reads and is not very durable. (W=3,R=1) gives slow writes but fast, durable reads.
💡 Push the cost onto the rarer operation; W+R must still exceed N.
Flashcard
Why is W < R (or generally 1 < r < w < n) often preferred, and what is wrong with R=1, W=N?
tap to reveal →
Most applications read more than they write, so the best throughput/availability comes when reads are cheaper than writes (W larger, R smaller). R=1, W=N is full replication (write-all, read-one): undesirable because if any server is unavailable the write cannot complete.
💡 Reads dominate, so make reads cheap; never force write-all.
Flashcard
Name uses of quorum beyond bounding read staleness in databases.
tap to reveal →
Cluster management uses quorum to decide which nodes form the 'active' cluster, avoiding split-brain. Consensus protocols like Paxos and Raft require a quorum (majority) to achieve agreement on system state or an operation's outcome.
💡 Quorum also kills split-brain and powers Paxos/Raft consensus.
Q1. In a leaderless store with N replicas, what does the condition W + R > N guarantee?
Q2. A 5-node cluster uses a majority quorum (W=R=3). How many node failures can a write tolerate?
Q3. For N=5, the product wants cheap (fast) writes while still satisfying the quorum overlap. Which W,R is valid and minimizes write cost?
Q4. Why is an odd number of total nodes recommended for a quorum cluster?
Q5. What problem does a quorum specifically help prevent in cluster management?