03
Raft & Paxos
The two famous consensus algorithms. Same guarantee, different ergonomics.
Raft was designed to be understandable. It elects a single leader for a term; the leader takes all writes, appends them to a replicated log, and an entry is committed once a majority has stored it. If the leader goes silent, followers time out and a new election starts. It powers etcd, Consul, and CockroachDB.
Raft — elect, then replicate
Follower
times out
→
Candidate
requests votes
→
Majority?
→ Leader
→
Replicate log
to followers
A higher term always wins, so a recovered old leader steps down — no split brain.
Paxos reaches the same safety with proposers, acceptors, and learners, but is famously hard to reason about and implement; Multi-Paxos adds a stable leader for efficiency. In interviews you rarely need the internals — what matters is knowing that a majority-quorum algorithm gives you safe agreement, and reaching for an existing implementation rather than writing your own.