/ writing

Explaining distributed consensus to my younger self

When I first met Raft, the paper was the problem. Terms, log indices, commit points — every sentence assumed I already cared about a problem I hadn't felt yet. So let me explain it the way I wish someone had explained it to me: with one leader, one whiteboard, and a room full of people who don't trust each other.

The room of untrustworthy scribes

Imagine five scribes in a room writing down a shared story, one line at a time. They can't see each other's pages directly, messages between them get delayed or lost, and any of them can leave the room without warning. The goal isn't elegance — it's that every scribe who is still in the room ends up with the same lines in the same order, or clearly can't participate.

That's consensus. Not 'everyone agrees forever', but 'a majority agrees now, and the agreement is permanent'. The majority part is the whole trick: if more than half of the scribes saw line 14 get written, no later decision can un-write it, because any future majority must overlap with that one.

Why a leader at all

You could let everyone propose lines at once. Paxos does, and it works — but the explanations never got shorter. Raft's compromise is simple: at any moment, exactly one scribe leads. Clients talk to the leader; the leader appends lines to its own page and replicates them; everyone else just follows along until the leader goes quiet.

A leader doesn't remove the disagreement. It serialises it.

Terms — the numbered 'election rounds' — exist because leaders do go quiet. When a follower stops hearing from the leader, it doesn't assume the leader is dead; it starts a new term and asks for votes. The rule that keeps history safe: a scribe only votes for someone whose story is at least as complete as its own. That single constraint is why a stale leader can never win.

What I'd tell my younger self

Consensus is not a library you install; it's a contract you enter. Read the commit rule before the RPC diagrams. Draw the timeline where a leader partitions away, comes back, and finds a higher term — that drawing teaches more than the whole paper. And be suspicious of anyone who says they 'simplified' it. The five-page paper is the simplification.