Quorum
Overview
In a distributed system, a quorum is the minimum number of nodes that must agree on an operation (like a read or a write) for it to be considered successful. Quorums are the mechanism used to guarantee consistency in replicated data stores, ensuring that reading data will always return the most recent write.
Key Concepts
The core formula for a strict quorum is R + W > N, where:
- N = Total number of replicas for a given piece of data.
- W = The write quorum (number of nodes that must acknowledge a write).
- R = The read quorum (number of nodes that must respond to a read).
As long as R + W is strictly greater than N, the read set and the write set will always overlap. When reading, the client receives responses from R nodes, compares their timestamps (or version vectors), and picks the most recent one. This guarantees strong consistency in a masterless (leaderless) system like Cassandra or DynamoDB.
Common Quorum Configurations
| Configuration (N=3) | R + W > N? | Characteristics |
|---|---|---|
| W=3, R=1 | Yes (3+1 > 3) | Fastest reads, but writes are slow and fail if even one node is down. |
| W=1, R=3 | Yes (1+3 > 3) | Fastest writes, but reads are slow and fail if one node is down. |
| W=2, R=2 | Yes (2+2 > 3) | The standard compromise. Balances read/write latency and survives one node failure. |
| W=1, R=1 | No (1+1 < 3) | Eventual consistency. Fast everything, but reads might return stale data. |
Trade-offs
Quorums trade latency for consistency. To achieve strong consistency, you must wait for multiple network round trips. If you want lower latency, you must lower W or R, which drops you into eventual consistency. Furthermore, strict quorums reduce availability during network partitions (the CAP theorem in action): if W=2 and a network partition leaves only 1 node reachable, all writes will fail.
Interview Tips
- Memorize the formula:
R + W > Nguarantees strong consistency in leaderless replication. - If designing a read-heavy system (like a user profile service), propose W=N, R=1 to optimize reads, but acknowledge the write availability hit.
- If designing a write-heavy system (like metrics collection), propose W=1, R=N (or W=1, R=1 for eventual consistency).
- Distinguish a read/write quorum (tuning data freshness) from a consensus majority quorum (preventing split-brain).
Summary
- A quorum is the minimum number of nodes required to agree on a read or write.
- If Read Quorum (R) + Write Quorum (W) > Total Replicas (N), strong consistency is guaranteed.
- The overlap ensures that every read touches at least one node containing the latest write.
- W=2, R=2 (for N=3) is the most common configuration, balancing speed and consistency.
- Lowering R or W below the quorum threshold results in eventual consistency.