Skip to content

Consensus with Raft

How Raft elects one leader per term, replicates a log, decides when an entry is committed, and what a leader stranded in a minority can and cannot do.

35 min8 steps

By the end you can
  • Compute majority sizes and the number of failures a Raft cluster tolerates
  • Explain how terms, single votes and randomised timeouts elect at most one leader per term
  • Decide which log index is committed from the followers' match indexes, including the current-term rule
  • Predict what a leader cut off in a minority partition can and cannot do

Why replicas need consensus

Same commands, same order

  • Every replica reaches the same state
  • The hard part is the order of slot 42

FLP (1985)

  • No always-terminating algorithm
  • Asynchronous, even one crash

Paxos and Raft

  • Safety always
  • Liveness when timeouts work

Why not skip consensus and have each replica apply writes in order of their wall-clock timestamps?

Answer this step to continue.