# Why Distributed Consensus Needs a Quorum

> Replicate data across five machines and you'd think any one of them could answer. But to stay consistent through failures, a majority has to agree on every decision. Here's the arithmetic behind quorums.

URL: https://harshith.in/blog/quorum-and-consensus/
Author: Harshith Sunku (Staff Engineer) — https://harshith.in/about/
Tags: distributed-systems, systems

You replicate your data five ways for safety. A write lands on the leader — so
which replicas must confirm it before you call it durable? Answer "one" and a
crash loses data. Answer "all" and a single slow node freezes the system. The
right answer is **a majority**, and the reason is a small, beautiful piece of
arithmetic.

## The Problem: Two Truths

The danger in a distributed system is **split-brain** — two halves of a cluster
that lose contact and each decide they're in charge. Both accept writes, and now
you have two divergent versions of reality with no way to merge them.

To prevent this, every decision needs the agreement of a **quorum**: a subset of
nodes large enough that two quorums can never both form at the same time.

## The Majority Trick

Set the quorum to a strict majority — more than half. In a 5-node cluster, that's
3. The key property:

```text
   any two majorities of 5 must share at least one node

   {A B C}   and   {C D E}   overlap at C
   {A B C}   and   {A B D}   overlap at A, B
```

Because any two majorities **overlap in at least one node**, two conflicting
decisions can't both gather a quorum — the shared node would have to vote for
both, and it won't. Split-brain becomes mathematically impossible.

## Read and Write Quorums

The same overlap logic lets you tune reads vs writes. With `N` replicas, a write
quorum `W` and read quorum `R`, you get strong consistency when:

```text
   W + R > N      →  every read quorum overlaps every write quorum
   W > N / 2      →  writes can't conflict with each other
```

For `N = 5`: `W = 3, R = 3` is the balanced choice. Want faster writes? `W = 2`
breaks the guarantee. Want fast reads at the cost of slow writes? `W = 5, R = 1`
— but now any down node blocks all writes.

```text
   N=5, W=3, R=3
   write → {A B C}
   read  → {C D E}     reads see C, which has the latest write ✓
```

## Why Clusters Are Odd-Sized

A majority of 4 is 3 — the same as a majority of 5. So a 4-node cluster tolerates
*one* failure, exactly like 3 nodes, while costing more and being likelier to
have a failure. Odd sizes give you the best failure tolerance per node:

```text
   nodes   majority   failures tolerated
     3        2              1
     4        3              1     ← extra node buys nothing
     5        3              2
```

This is why Raft and Paxos clusters are almost always 3 or 5.

## Takeaways

- A quorum is a subset big enough that any two quorums overlap — which is what
  makes conflicting decisions impossible.
- A strict majority is the smallest such quorum; it prevents split-brain because
  two majorities always share a node.
- `W + R > N` and `W > N/2` give strong consistency; tune `W`/`R` to trade read
  vs write speed.
- Use odd cluster sizes — an even size costs more without tolerating more
  failures.
