‹ All demos
LiveDistributed systems · Built from scratch

Raft consensus, live

The algorithm that keeps etcd and Kubernetes consistent. Five servers elect a leader and replicate a log — crash them and split the network while it runs.

How it works

  1. 1Each server is a follower, a candidate or the leader. If a follower hears nothing from a leader before its timer runs out, it starts an election.
  2. 2The leader copies client commands to the others and commits an entry once a majority has it. A minority on the wrong side of a network split can never commit.
  3. 3The same safety checks as the test suite run on every step: at most one leader per term, and every server applies the same commands in the same order.
  4. 4The test suite runs 40 random scenarios of crashes, restarts and partitions and checks those rules after every millisecond.