Part II — Replication & Consensus · Chapter 2

Quorum systems

Hook

You've got 5 replicas. How many do a read and a write each need to touch so that a read can never miss the latest write — without waiting for all 5 every time?

Intuition

Drag R and W. Notice: some combinations guarantee that any read quorum and any write quorum you could pick are forced to share at least one node. Others leave a gap — a read could land entirely on nodes the write never reached.

Formalize

A quorum system replicates to NN nodes and requires a write to succeed on WW of them, a read to be answered by RR of them. Reads and writes are safe together exactly when:

R+W>NR + W > N
  • NN — total number of replicas.
  • WW — how many replicas a write must reach before it's considered done.
  • RR — how many replicas a read must query before it returns an answer.
  1. Why the inequality works

    Out of NN nodes, a write quorum covers WW of them and a read quorum covers RR of them. If R+W>NR + W > N, there simply aren't enough "empty" slots left for the two quorums to avoid each other — by the pigeonhole principle they must share at least one node.

  2. That shared node is the guarantee

    Whatever node sits in the overlap has the latest write, because the write quorum included it. So any read quorum is guaranteed to see it too.

Play

Watch the readout compute R+WNR + W - N directly — the overlap margin. Positive means safe, zero or negative means a read and a write could pick disjoint sets of nodes and a stale read slips through.

Worked example

N=5N = 5, and you choose R=3R = 3, W=3W = 3:

  1. Pick concrete quorums

    Label the replicas 1–5. Say the write quorum is {1,2,3}\{1, 2, 3\} and the read quorum is {3,4,5}\{3, 4, 5\}.

  2. Find the overlap

    They share node 33 — whatever the write left there, the read sees it.

  3. Check the margin
    R+WN=3+35=1R + W - N = 3 + 3 - 5 = 1

    A margin of exactly 1 means every possible pair of a 3-node read quorum and a 3-node write quorum out of 5 shares at least one node — not just this particular pair.

  4. Contrast with an unsafe choice

    R=2,W=2R = 2, W = 2 gives a margin of 2+25=12 + 2 - 5 = -1: a read quorum like {4,5}\{4, 5\} and a write quorum like {1,2}\{1, 2\} share nothing, so the read could miss the write entirely.

Checkpoint

N is fixed at 5. Find R and W that guarantee overlap while contacting the fewest nodes possible — i.e. R + W is exactly one more than N.

Drag R and W to try a combination
Summary
R+W>NR + W > N

A quorum system replaces "wait for the one primary" with "wait for enough replicas to overlap." Any RR and WW satisfying R+W>NR + W > N guarantee a read always sees the latest committed write — and the smallest safe choice, R+W=N+1R + W = N + 1, gets that guarantee while touching the fewest nodes possible.