SysDesignAtlas

Quorums

Why R + W > N works, what it does and does not guarantee, sloppy quorums, and the anti-entropy machinery that keeps leaderless replicas converging.

HLDMedium10 min readquorumreplicationconsistency
Confidence

#The idea

A quorum is simply "enough of them" — the minimum number of copies that must take part for an operation to count.

In a leaderless system (Dynamo-style) there is no primary holding the official version, so a client asks several copies and relies on overlap: if the group it writes to and the group it reads from must share at least one member, the read cannot miss the write.

   N = number of replicas holding each key
   W = replicas that must acknowledge a write
   R = replicas that must respond to a read

   If  R + W > N,  the read set and write set must
   share at least one replica → the read sees the write.

The picture, with N=3, W=2, R=2:

   write to A, B (ack) ──►  A[v2]  B[v2]  C[v1]
                             ▲      ▲
   read from B, C ───────────┘      │
                    B has v2, C has v1
                    → overlap guarantees v2 is seen;
                      version numbers pick the winner

Any 2 of 3 replicas must include at least one of the 2 that took the write. Pigeonhole principle — that's the whole mechanism.

#Tuning the dials

The same N gives you very different systems:

ConfigBehaviour
N=3, W=2, R=2Balanced. Tolerates 1 failure for both reads and writes. The default.
N=3, W=3, R=1Very fast reads; writes fail if any replica is down. Good for read-heavy, rarely-written data.
N=3, W=1, R=3Very fast writes; reads must reach everyone. Rarely useful.
N=3, W=1, R=1Fastest, no overlap guarantee. Pure eventual consistency.
N=5, W=3, R=3Tolerates 2 failures. More durable, higher latency.

Latency implication: you wait for the W-th fastest response, not the slowest. So higher N with the same W can actually reduce tail latency (the slowest few percent of requests). Example: with N=3, W=2, one slow replica out of three hurts you often. With N=5, W=2, you only need the 2 fastest of 5, so one or two slow replicas rarely matter. That's a nice, non-obvious point to raise.

#What quorums do NOT give you

The most important part, and the part that is usually rushed.

R + W > N does not give linearizability. It guarantees a read overlaps a completed write. It does not guarantee that every replica agrees on one order of writes, or that a read sees a write the instant it happens. Concretely:

  • Concurrent writes still conflict. Two clients write different values to overlapping quorums simultaneously. Both succeed. Now replicas hold different values and something must resolve them. Either last-write-wins (keep the one with the later timestamp and silently drop the other — data is lost), or version vectors, which detect that the writes were concurrent and keep both versions ("siblings") for the application to merge.
  • Partial writes are not rolled back. A write that reaches 1 of 3 replicas and then fails is reported as failed to the client — but that one replica keeps the value. A later read may return it. The failed write "succeeds" later.
  • Reads can go backwards. Two successive reads hitting different replica subsets can return v2 then v1, violating monotonic reads (the promise that once you've seen a value, you never see an older one).
  • No atomicity across keys. Quorums are per-key. Moving £10 from account A to account B is two separate quorum writes, and one can succeed while the other fails.

#Sloppy quorums and hinted handoff

Every key has a set of machines that are supposed to hold it — its home replicas, picked by hashing the key. A strict quorum insists that W of those specific machines accept the write. If too many of them are unreachable, the write fails: you've chosen consistency over availability.

Sloppy quorum takes availability instead: accept the write on any W reachable nodes, even ones that don't normally own the key.

   Home replicas for key K: A, B, C.  A and B are unreachable.

   Strict quorum (W=2):  write FAILS
   Sloppy quorum:        write goes to C, D, E
                         D and E store a HINT: "this belongs
                         to A / B; deliver when they return"

Hinted handoff is the delivery half: D and E hold the data temporarily and forward it once A and B are healthy.

This substantially raises write availability — but note it breaks the overlap guarantee entirely. A read from a strict quorum of {A, B, C} may miss the write that landed on {C, D, E}. Sloppy quorums are a durability-and-availability mechanism, not a consistency one. Being precise about that distinction is what keeps the rest of the reasoning sound.

#Anti-entropy

Anti-entropy means any process that finds and fixes differences between replicas. It's needed because with no leader deciding what every replica should hold, replicas drift apart — a replica that was down misses writes, a partial write lands on only some copies. Three mechanisms pull them back together:

1. Read repair. During a read, the coordinator (whichever node is handling this request) sees replicas returning different versions. It returns the newest to the client and writes it back to the stale replicas. This repairs frequently read (hot) data for free — but data nobody reads (cold data) never gets repaired this way.

2. Hinted handoff. As above — covers temporary unavailability.

3. Merkle trees. For the cold data problem: a hash tree over each replica's key ranges.

              root hash
             /         \
        h(A)             h(B)          Compare roots.
       /    \           /    \         Equal → identical, done.
    h1      h2       h3      h4        Differ → descend only
   /  \    /  \     /  \    /  \       into the differing subtree.
  keys keys keys  keys keys keys

Two replicas compare root hashes. If equal, they're in sync — one comparison for the whole range. If not, they descend only into subtrees that differ, so the amount of data exchanged is proportional to the number of differences, not the size of the dataset. This is what makes background repair affordable across terabytes.

#Quorum reconfiguration

An under-discussed subtlety worth knowing: changing N (adding or removing replicas) can break the overlap guarantee mid-transition, because old and new quorums may not intersect. Example: you go from N=3 {A, B, C} to N=5 {A, B, C, D, E}. A write under the old config lands on {A, B}. A read under the new config asks the majority {C, D, E} — no overlap, so the read misses the write.

Systems handle this with joint consensus (Raft's approach — briefly require majorities in both old and new configurations) or by changing membership one node at a time, so consecutive configurations always overlap. If you're ever asked "how do you add a replica safely?", this is the answer.

#Quorum vs consensus

They're related but not the same thing, and mixing them up is common.

Quorum (Dynamo-style)Consensus (Raft/Paxos)
CoordinatorNone — any nodeElected leader
OrderingNone; conflicts possibleTotal order guaranteed
ConflictsApplication/CRDT resolvesImpossible by construction
ConsistencyPer-key recency (tunable)Linearizable
Write pathClient → W replicasClient → leader → majority
AvailabilityHigher (no election gap)Lower (minority can't serve)
Best forHigh-availability data storesCoordination, metadata, locks

Consensus uses quorums (a majority must ack), but adds a leader and a totally ordered log. Quorums alone give you overlap without order — which is cheaper, more available, and weaker.

#In an interview

The scoring answer connects the dials to the requirement:

"I'll use N=3 across three availability zones with W=2, R=2. That tolerates one replica or one AZ failing without losing availability for reads or writes, and the overlap means a read sees the last completed write. It does not give me linearizability — concurrent writes to the same key will conflict, so I need a resolution strategy. For the like counter that's fine; I'd use a CRDT counter so conflicts merge correctly. If this were inventory, quorums wouldn't be enough and I'd move to a consensus-backed store."

That paragraph names the configuration, the failure tolerance, the guarantee, the limit of the guarantee, and the mitigation — and then shows where the whole approach stops being appropriate.

#Check yourself

Why does R + W > N guarantee a read sees the latest completed write?Show answer
The read set and write set must share at least one replica (the pigeonhole principle), and version numbers pick the newest value among the responses.
N=3: what do W=3, R=1 and W=1, R=1 give you?Show answer
W=3, R=1: very fast reads, but a write fails if any replica is down. W=1, R=1: fastest, with no overlap guarantee — pure eventual consistency.
Why can higher N with the same W reduce tail latency?Show answer
You wait for the W-th fastest replica, not the slowest, so more replicas means more to race.
Name three things R + W > N does not give you.Show answer
Linearizability: concurrent writes still conflict; a failed partial write can survive on one replica and appear later; successive reads can go backwards; and there's no atomicity across keys.
What does a sloppy quorum trade?Show answer
It accepts writes on any W reachable nodes when home replicas are down — much higher write availability — but breaks the overlap guarantee, so a strict-quorum read may miss the write.
How do Merkle trees make background repair affordable?Show answer
Replicas compare root hashes and descend only into subtrees that differ, so data exchanged is proportional to the differences, not the dataset — catching cold data read repair never touches.
Quorum versus consensus: what's the core difference?Show answer
Quorums give per-key overlap with no coordinator and no ordering, so conflicts are possible. Consensus adds an elected leader and a totally ordered log — linearizable but less available.

#What to carry forward

  • R + W > N forces read and write sets to overlap, so reads see the latest completed write.
  • It is not linearizability: concurrent writes conflict, failed writes linger, reads can go backwards.
  • Tune N, R and W per workload; you wait for the W-th fastest replica.
  • Sloppy quorums and hinted handoff buy availability at the cost of overlap; read repair and Merkle trees restore convergence.
  • Use quorums for highly available data, consensus for coordination and anything needing total order.
00:00
/ 10m