Takeaway

Raft decomposes consensus into leader election, log replication, and safety; its design emphasizes understandability without sacrificing performance.

The problem (before → after)

  • Before: Paxos is correct but hard to implement.
  • After: Raft provides a practical protocol with clear roles and invariants.

Mental model first

A class president (leader) is elected by majority; they propose assignments (log entries) and ensure everyone writes them in the same order; if they fail, a new election is held.

Just-in-time concepts

  • Terms and voting; election timeouts.
  • Log matching: same index/term implies identical prefix.
  • Commit rules: entry is committed once stored on a majority and leader’s term.

First-pass solution

Followers start elections on timeout; candidates request votes; leader appends entries and sends AppendEntries RPCs; followers reject inconsistencies; leader backs up.

Iterative refinement

  1. Snapshotting truncates logs; install snapshot RPC.
  2. Cluster membership changes with joint consensus.
  3. Linearizable reads via leader lease or read-index.

Principles, not prescriptions

  • Strong leader simplifies reasoning and performance.
  • Preserve safety invariants across elections.

Common pitfalls

  • Mismanaging timeouts causing split votes.
  • Incomplete log consistency checks.

Connections and contrasts

  • See also: [/blog/consensus-paxos], [/blog/byzantine-fault-tolerance], [/blog/cap-theorem].

Quick checks

  1. Why leader-based? — Simplifies replication and ordering.
  2. When is an entry committed? — On majority and leader’s term.
  3. How to reconfigure? — Joint consensus phase.

Further reading

  • Ongaro & Ousterhout (source above)