Quorum intersection
Distributed systems · Intro
With N replicas, if every write reaches W of them and every read asks R of them, then R + W > N guarantees each read meets the latest write.
Try this
Set N = 5 and W = 3, then slide R down from 3 to 2. Watch the read set slip past every replica that holds the write.
Why it matters
It is the arithmetic behind tunable consistency in Dynamo, Cassandra and Riak: choose R and W, and you have chosen how fresh your reads are.
The proof
Put the write on any W replicas and the read on any R replicas. To avoid each other completely, the two sets would need R + W different replicas.
There are only N. So if R + W > N, they cannot avoid each other: at least R + W − N replicas are in both, and the read sees the newest version there.
If R + W ≤ N, nothing forces an overlap. The worst case, shown in the visual, puts the write on the first W replicas and the read on the last R, and the read can return an old value.
The usual choice is a majority for both (R = W = ⌊N/2⌋ + 1). Trading R against W trades read speed against write speed without giving up the guarantee.
Sources
- Weighted voting for replicated data, David K. Gifford, 1979
- Dynamo: Amazon’s Highly Available Key-value Store, G. DeCandia et al., 2007