← Back
← Back to Projects
· 5 min read

Raft Consensus

Distributed SystemsBackendAlgorithms

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.

RAFT CONSENSUS CONSENSUS
TERM 1 QUORUM 5/5
N0LEADERN1FOLLOWERN2FOLLOWERN3FOLLOWERN4FOLLOWER
EVENT LOG
N0 elected leader — Term 1
Leader sending heartbeats to all followers
Leader Follower Candidate Down

The protocol

Raft maintains consensus through three mechanisms:

  1. 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.

  2. Heartbeats — the leader continuously sends heartbeat pulses to all followers, who acknowledge them. This maintains authority and replicates the log.

  3. 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.