Consensus, quorums and the cost of agreement
Getting five machines to agree is not five times harder than one. It is a different kind of problem.
What you will be able to do
- Compute the quorum size for a cluster and explain why odd sizes are standard
- Explain what a Raft leader does and when a cluster stops accepting writes
- Reason about the latency cost of cross-region quorums
- Decide when a design actually needs consensus
Why a majority
A quorum is the smallest set of nodes that must agree for a decision to count. With majority quorums, any two quorums in the same cluster share at least one member, so a node in the overlap can carry the newest decision from one quorum to the next. That overlap is the whole trick.
N = 5 quorum = 3 tolerates = 2 failures N = 4 quorum = 3 tolerates = 1 failure (same as N = 3, more machines) write quorum W + read quorum R > N => read sees latest write N = 3, W = 2, R = 2 (2 + 2 > 3)
The N=4 line explains the industry habit of odd clusters. Four nodes cost 33% more than three and buy no additional failure tolerance, because a majority of four is three.
What Raft actually does
Latency is geography
A three-region cluster that requires a majority for every write pays a cross-ocean round trip on the critical path — often 150 ms or more, twice if the leader must confirm with a follower before replying. The usual fix is to keep the quorum inside one region and replicate asynchronously outward, accepting that a regional disaster loses recent writes.
Do you need it?
| Need | Cheaper answer | Consensus needed |
|---|---|---|
| Unique ids | Snowflake ids, UUIDs | No |
| One writer per entity | Partition ownership, sticky routing | Sometimes |
| Leader election for a job | Lease in a coordination service | Yes, but delegated |
| Config that must not diverge | Versioned config service | Yes |
| Money ledger ordering | Single-writer partition per account | Often no |
In a design round, name the coordination service rather than inventing consensus: etcd, ZooKeeper, or the Raft implementation inside the database you already chose. Describing Raft from memory is less impressive than knowing that you only need it for a handful of keys.
Worth remembering
- Majority quorums let any two quorums overlap by at least one node, which is what makes agreement possible.
- A five-node cluster survives two failures; a four-node cluster also survives only one.
- Cross-region consensus pays a round trip to the majority region on every write.
- Most features do not need consensus — they need a single writer per key, which is cheaper.