Quorum reads and writes

Distributed systems Senior Python 3.13+ PostgreSQL 17+ Reviewed By Best Latest Apps

Predict the output

Five replicas, writes need 3 acks. What is the smallest R that guarantees each read overlaps the last acknowledged write?

Python 3.13
N, W = 5, 3
R = next(r for r in range(1, N + 1) if W + r > N)
print(R)

Options
Hint 1 of 1

The sets must overlap: W + R > N.

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A 3

Correct. 3 + 3 = 6 > 5, so any 3 read replicas include one of the 3 written.

Every read set of R replicas overlaps the latest write set of W only when R + W > N, which here means R > 2. The smallest whole number that works is 3.

Why not the others?
  • B 2. 3 + 2 = 5, not greater than 5: the two sets can miss each other.
  • C 1. One replica may be one that didn't get the write.
  • D 5. Works but isn't the smallest.

30-second answer

If every write must be acknowledged by W replicas and every read asks R replicas, then W + R > N means the read set and the write set overlap in at least one replica, so a read normally sees the latest acknowledged write. It's not a full guarantee: concurrent writes, sloppy quorums that write to stand-in nodes, failed writes that partly applied, and clock-based conflict resolution can all still return stale or lost values.

Practise saying it · 35 s. No recording, just a timer

Explain quorum reads and writes.

Say your answer out loud, then check which of these points you covered:

  • W + R > N means overlap
  • 3/2/2 tolerates one failure
  • Not linearizable by itself
  • Read repair, anti-entropy

Deep dive

N = 3, W = 2, R = 2 is the common setting: tolerates one slow or down node for both reads and writes.

W = N, R = 1 makes reads fast but any one down replica blocks writes.

Read repair and anti-entropy (Merkle trees) bring stale replicas up to date.

Linearizable reads need more, such as read repair before returning.

Common mistakes

  • Thinking W + R > N gives linearizability.
  • Setting W = 1 for speed and then being surprised by lost writes when that node dies.
  • Forgetting that a quorum write that fails may still have reached some replicas.

Senior take & follow-ups

Show the overlap argument, give the 3/2/2 example, and list the edge cases.

Follow-up questions

Think of your answer first, then open the hint.

  1. What does W = 1, R = 1 give you?

    Show hint

    Fast, available, and no overlap guarantee: stale reads are normal.

  2. What is a sloppy quorum?

    Show hint

    Accepting writes on nodes outside the key's home set during an outage, handed back later.

Suggest a fix if something here is wrong or out of date.