Want the details?
What is a quorum?
To survive a broken server, a database keeps several copies (replicas) of each value, usually N = 3. Copying takes time, and some replicas are slower or farther away. So the database must decide how many copies to wait for.
A quorum is that number. A write is confirmed when W replicas have it. A read asks R replicas and keeps the newest answer. If R + W > N, every set of R replicas overlaps every set of W replicas, so at least one replica in every read has the newest confirmed write. If R + W ≤ N, a read can miss it.
How to read the bench
| Part on the bench | What it means in a real system |
|---|---|
| Box at the left | The writer (a client). Its number is the last confirmed version. |
| Ball on a lane | A write on its way to one replica. Replica 1 is near (0.3 s), 2 is farther (1.2 s), 3 is far (2.6 s). |
| Replica boxes | The three copies. The number on top is the version each holds. A cross: it is down. |
| Lit wires | The replicas that answered the last read. |
| Box at the right | The reader. Its number is the value it got; a cross means the value was older than the last confirmed write. |
The numbers
- N = 3 replicas. A new version every 2 s after the previous one is confirmed. A read every 0.6 s.
- W = 1, R = 1: about a third of reads are stale; 26 versions a minute.
- W = 2, R = 2: no stale reads; 19 versions a minute; still works with one replica down.
- W = 3, R = 1: no stale reads; 13 versions a minute; with one replica down, no write is ever confirmed.
- W = 1, R = 3 with one replica down: every read fails.
The test checks these numbers, and that with R + W > 3 no read is ever stale through hundreds of random changes of W, R and outages.
In real systems
- Apache Cassandra lets you choose the consistency level per query: ONE, QUORUM, ALL. QUORUM for both reads and writes gives R + W > N.
- Amazon's Dynamo paper made N, R and W famous; Riak followed the same idea.
- Raft and Paxos (the replication lab) also use majorities: a write is safe once a majority has it.
- Even with R + W > N, some edge cases remain in real systems (writes that fail half-way, clocks that disagree). Databases add tools such as read repair and version vectors.
- Tune for the workload: many reads? Use a small R and a large W. Many writes? The opposite.
Words to know
- Replica
- One copy of the data, on its own server.
- N, W, R
- Number of copies; copies a write waits for; copies a read asks.
- Stale read
- A read that returns an older value than one already confirmed.
- Quorum
- The number of replicas that must agree, chosen so that groups overlap.
- Eventual consistency
- The replicas will agree in the end, but a read right now may be old.