Raft Consensus
Raft Consensus
A live simulation of the Raft consensus protocol running across a 5-node cluster. Watch leader election, heartbeat propagation, node failure, and automatic recovery in real time.
The protocol
Raft maintains consensus through three mechanisms:
Leader election — when the leader crashes, followers detect the missing heartbeat. A random follower becomes a candidate, increments the term, and requests votes. A majority wins the election.
Heartbeats — the leader continuously sends heartbeat pulses to all followers, who acknowledge them. This maintains authority and replicates the log.
Fault tolerance — the cluster tolerates up to 2 node failures (maintaining quorum at 3/5). Dead nodes rejoin as followers and sync to the current term.
Implementation
Pure Svelte 5 + SVG. Nodes are positioned on a ring with messages animating between them. The event log panel captures every state transition. Color coding makes the protocol state immediately readable — gold for leader, blue for followers, yellow during elections, red for failures.