Home > Distributed Systems

In Search of a Leader: Understanding Raft Consensus

February 14, 2026

In the world of distributed systems, getting a cluster of nodes to agree on something—like the order of log entries—is notoriously difficult. This is the problem of Consensus.

The Split Brain Problem

Imagine a cluster of database nodes. If the network partitions, splitting the cluster into two isolated groups, both groups might try to accept writes independently. This leads to a "Split Brain" scenario, where data diverges and consistency is lost. To prevent this, systems need a reliable way to elect a single leader that coordinates all updates.

Enter Raft

Raft is a consensus algorithm designed to be easy to understand (compared to Paxos). It operates by electing a distinguished Leader, who then manages the replicated log. Raft decomposes the consensus problem into three relatively independent subproblems:

Node States

At any given time, each server is in one of three states:

The Election Process

Raft uses a heartbeat mechanism to trigger leader election. When servers start up, they begin as followers. A server remains in the follower state as long as it receives valid RPCs from a leader or candidate.

If a follower receives no communication over a period of time called the election timeout, then it assumes there is no viable leader and begins an election to choose a new one:

  1. It increments its current term.
  2. It transitions to Candidate state.
  3. It votes for itself and issues RequestVote RPCs in parallel to each of the other servers in the cluster.

A candidate wins an election if it receives votes from a majority of the servers in the full cluster for the same term. Once a candidate wins, it becomes the Leader.

Interactive Visualization

Below is a simulation of the Raft election process. You can see the nodes transitioning between states. Try clicking "Kill Leader" to simulate a failure and watch the cluster elect a new leader.