LESSON 04 · Consistency tradeoff

Choose read and write acknowledgments

W and R determine how many replicas a coordinator waits for.

SYSTEM VIEW

The storage path

Diagram view
Replicas (N)—
Write (W)—
Read (R)—

Watch a write wait for two of three replicas and a read ask two, then try the lab’s settings.

  1. The Client puts v2 of order:42. The Coordinator sends it to all three replicas (N = 3) and answers ok once two acknowledge (W = 2). A and B ack and hold v2; C’s copy is delayed, so C still holds v1.

    N
    3 replicas: A, B, C
    W
    2 acks: A and B

    What changed

    • v2 on Replicas A and B
    • Client told ok after 2 acks
    • C’s copy delayed: still v1
  2. A moment later the Client reads order:42. The Coordinator waits for two answers (R = 2), and this time they come from B and C. B answers v2 and C answers v1, so the two disagree.

    R
    2 answers
    Asked
    B and C

    What changed

    • Read asks B and C
    • Answers: v2 and v1
  3. The Coordinator returns v2 because its version is newer than v1. W + R = 4 is more than N = 3, so any two replicas that took a write share at least one with any two that answer a read. Here that replica is B.

    W + R
    4 > 3: overlap
    Read got
    v2 (B) · v1 (C)

    What changed

    • Client gets v2
    • B took the write and answered
  4. The Client puts v3, and so far it reaches only A. A acks, but that is one of the two acks W = 2 needs, so the put hasn’t finished and the Client has no answer yet. B still holds v2 and C v1.

    v3
    on A only, not acked
    Latest acked
    v2

    What changed

    • v3 on Replica A
    • Put of v3 waits: 1 of 2 acks
  5. Meanwhile a read asks A and B. A answers v3 and B answers v2, and the Coordinator returns v3, the newer version, even though the put of v3 hasn’t finished.

    Read asks
    A and B
    Answers
    v3 (A) · v2 (B)

    What changed

    • Client reads v3
  6. A later read asks B and C, gets v2 and v1, and returns v2: older than the v3 already read. That isn’t linearizable: once a read returns a value, no later read may return an older one.

    Read 1: A + B
    v3
    Read 2: B + C
    v2, older
    Closes it
    write-back reads, Raft

    What changed

    • Client reads v2 after v3
  7. Waiting on more replicas costs latency and availability. The lab’s Replicas 1–3 are A–C. W = R = 2: any two include A or B. W = R = 1: only A holds v2, so 2 in 3 reads are stale. W = 3, C down: writes fail.

    W = R = 2
    stale 0% · 1 down ok
    W = R = 1
    fastest · stale 67%
    W = 3
    fails with 1 down

    What changed

    • W and R set as in the lab
    • Each starts just after v2 is acked
    Settings

Space plays · ← → step · Home resets

Can this quorum return stale data?

A write was just acknowledged by W replicas, and the others haven’t caught up yet. A read now asks R replicas. Set N, W, and R, take replicas down, and predict what the read can see.

3
1
1

Select a replica to take it down or bring it back

With N=3, W=1, R=1, can a read return the older value?

Commit to an answer first. Being wrong here is the useful part.

What this model assumes
  • Worst case: exactly W replicas hold the write, and nothing has caught up yet. Real systems usually converge within moments through background replication and read repair.
  • A read chooses R replicas evenly from those that are reachable.
  • Replicas that fail keep whatever they had, and new writes in this model need W reachable replicas.
  • An overlapping quorum isn’t the same as linearizability: concurrent writes, partial failures, and sloppy quorums can still produce surprises. See the Key-Value Store and Consensus chapters.
THE IDEA

How it works

A quorum is the number of replicas that must respond before an operation counts as done. Let N be replica count, W required write acknowledgments, and R required read responses. With N = 3 and W = R = 2, any two replicas that took a write share at least one replica with any two that answer a read. For example, A and B acknowledge v2 while C still holds v1. A read reaches B and C, receives v2 and v1, and returns v2 because its version is newer.

Waiting for more responses raises latency, since a slower replica now counts, and can lower availability: with N = 3, W = 3 fails when one replica is down, while W = 2 tolerates it. W = 1 acknowledges quickly but leaves a larger stale-read and data-loss window. Cassandra exposes this choice per request through consistency levels such as ONE and QUORUM.

The W + R > N rule provides overlap under a stable replica set, but not linearizability. Linearizable means every operation appears to take effect at one instant between its start and finish, so once a read has returned a value, no later read returns an older one. Quorums can break this: an unfinished write reaches only A, one read through A and B returns the new value, then a later read through B and C returns the old one. Sloppy quorums and changing membership add more gaps. Closing them takes further rules, such as reads that write back what they saw, or consensus, as etcd does with Raft.

DECISION POINT

N = 3, W = 1, R = 1. A write succeeds on one node and a read goes to a different node. What can happen?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • W + R > N gives overlap for fixed replica sets, subject to assumptions.
  • Tune quorum settings to latency, freshness, and failure needs.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
ApplyQUESTION 01

N = 5 and W = 3 on a fixed replica set. What is the smallest R that guarantees a read overlaps every acknowledged write?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.