Lesson 10 of 17
16. Consistency and CAP

16.9 How do quorums give tunable consistency?

3 min read+10 XP

In practice

At the bank: With three counters, a rule: a withdrawal counts once two counters record it, and a balance check asks two counters and believes the newer figure. Because any two counters out of three share at least one, you always see the latest withdrawal.

In the system: Leaderless stores (Chapter 14, section 14.10) let you tune consistency per request with N, W and R:

  • W + R > N (for example N = 3, W = 2, R = 2): read and write sets overlap, so reads usually see the latest write. Good for the wallet balance, at the cost of waiting for two replicas each time.
  • W + R ≤ N (for example W = 1, R = 1): fastest and most available, but reads may be stale. Fine for view counts.

Two cautions:

  • Quorums alone don't make a system linearizable. Concurrent writes, writes that partly succeed then fail, and "sloppy" quorums can still produce surprising reads. Systems that need true linearizability use consensus, or extra steps like read repair before returning.
  • Quorum size sets fault tolerance. With N = 5, W = 3 and R = 3, you can lose 2 replicas and still read and write consistently; with W = 5, losing one replica blocks all writes.

Memory code: "Ask enough counters that the asking and the telling must overlap."