Try
↑ ↓ move↵ openesc close

Raft consensus lab

A cluster of three to seven nodes elects a leader and replicates a log. Crash nodes, cut the network, submit writes, and watch terms, votes and commit indexes keep the log consistent.

Crash or restart any node on its card.

term 0leader nonecommitted 0 entriesmajority 3 of 50 messages in flight

n0 followerterm 0

voted nobody, timer 360 ms

  1. empty log
commit 0 / 0
n1 followerterm 0

voted nobody, timer 480 ms

  1. empty log
commit 0 / 0
n2 followerterm 0

voted nobody, timer 470 ms

  1. empty log
commit 0 / 0
n3 followerterm 0

voted nobody, timer 580 ms

  1. empty log
commit 0 / 0
n4 followerterm 0

voted nobody, timer 390 ms

  1. empty log
commit 0 / 0

Solid cell: committed. Dashed: in the log but not committed. Colour of the border: the term the entry was written in. Grey card: cut off by the partition.

elections
0
split votes
0
writes committed
0 / 0
writes with no leader
0

What just happened

Waiting for the first election timeout.

Committed entries and term over time

Waiting for data. Press play or step the simulation.

What to try

Each one sets up a starting point. Then make the change it describes.

  1. Watch an election

    Press Reset and watch the first few seconds with the defaults. Read the event list.

    Look for. All nodes start as followers with no leader. The first node whose random timer fires becomes a candidate, asks for votes, and wins when a majority grants them. Then its heartbeats keep everyone else a follower.

  2. Crash the leader

    Wait for a leader, then press Crash on its card.

    Look for. Heartbeats stop. After an election timeout a follower runs for the next term and wins. Writes submitted while there was no leader are dropped, so a client has to retry. Restart the old node and watch it accept the new leader and its log.

  3. Split votes

    Set the election timeout to 150 ms and the network delay to 100 ms, then crash the leader a few times.

    Look for. When timeouts are close to the message delay, two nodes often run for the same term and split the vote. Nobody wins that term, both time out again, and the split vote counter climbs. Longer timeouts relative to the delay make this rare.

  4. A leader in the minority

    Wait for a leader and a few committed entries, then press Cut the leader into a minority. Submit a few writes while the partition holds.

    Look for. The old leader keeps appending to its own log, shown as dashed cells, but its commit index never moves because it cannot reach a majority. The other side elects a new leader in a higher term and keeps committing. Two leaders, but only one can commit.

  5. Heal and repair

    With the partition from the previous experiment in place, press Heal the network.

    Look for. The old leader hears a higher term and steps down. Its uncommitted dashed entries conflict with the new leader’s log, so they are deleted and replaced. Every log converges to the leader’s, and nothing that was committed is lost.

New to the idea? Read the lesson first. Every number here comes from a seeded simulator, so the same seed gives the same run.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms