Academy · Consistency & Consensus

Consensus: Raft & Paxos

Many machines must agree on one value/log order, surviving crashes and partitions — provably hard (FLP).

2 min read·8 sections
Open the interactive version → diagrams, practice & more

The problem

Many machines must agree on one value/log order, surviving crashes and partitions — provably hard (FLP).

The idea

Consensus algorithms use majority quorums to elect a leader and agree on a replicated log, staying safe through failures.

How it works

Raft (the understandable one): elect a leader; the leader appends entries to a majority before committing; on leader failure a new election runs. Any two majorities overlap, so conflicting decisions are impossible — at most one side of a partition can make progress.

The tradeoff

Strongly consistent and partition-safe, but writes need a round-trip to a majority (latency), and the minority side loses availability.

In the wild

etcd, Consul, CockroachDB, TiDB, Kafka's controller — all built on Raft/Paxos.

Deep dive

Flow

  1. Elect a leader via a majority vote (a term).
  2. Leader appends each entry to its log and replicates it.
  3. An entry commits once a majority has durably stored it.
  4. On leader loss a new election runs; overlapping majorities keep it safe.

Watch for

  • Writes need a majority round-trip — a latency floor you can't avoid.
  • The minority side of a partition can't make progress (no availability).
  • Use odd cluster sizes (3/5/7); even sizes waste a node on quorum.

Common trap

Explain safety from quorum overlap: any two majorities share a node, so no split decisions.

Common questions

What problem does Consensus: Raft & Paxos solve?

Many machines must agree on one value/log order, surviving crashes and partitions — provably hard (FLP).

How does Consensus: Raft & Paxos work?

Raft (the understandable one): elect a leader; the leader appends entries to a majority before committing; on leader failure a new election runs. Any two majorities overlap, so conflicting decisions are impossible — at most one side of a partition can make progress.

What are the tradeoffs of Consensus: Raft & Paxos?

Strongly consistent and partition-safe, but writes need a round-trip to a majority (latency), and the minority side loses availability.

Where is Consensus: Raft & Paxos used in production?

etcd, Consul, CockroachDB, TiDB, Kafka's controller — all built on Raft/Paxos.

Part of Academy on SystemLore — system design explained with 148 deep topics, interactive diagrams, and a build-it-yourself game. Browse the glossary and "X vs Y" comparisons, or build this one →