Fundamentals 5 min read

Understanding Raft: A Simple Guide to Distributed Consensus

This article introduces the classic Paxos algorithm, explains why it is considered complex, and then presents the more approachable Raft consensus protocol, detailing its node roles, leader election, log replication process, and useful resources for deeper learning.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Understanding Raft: A Simple Guide to Distributed Consensus

The most famous distributed consistency algorithm is Paxos, proposed in 1990 and used by Google’s Chubby lock service. Subsequent algorithms, such as ZooKeeper’s ZAB, are variations of Paxos, but Paxos is often regarded as complex and hard to understand.

In 2013, two researchers at Stanford designed Raft with simplicity in mind. Raft is now widely adopted; notable examples include etcd and the service‑discovery component of Google’s Kubernetes.

What is distributed consistency?

In a single‑node environment, a client sends a value to a node and consensus is trivial. When multiple nodes are involved, achieving consistency becomes a challenge.

Raft is designed to solve this distributed consistency problem.

Raft’s approach

Each node can be in one of three states:

Follower

Candidate

Leader

All nodes start as followers.

If a follower does not receive a heartbeat from a leader, it becomes a candidate and requests votes from other nodes to become the leader.

When a candidate receives votes from a majority of nodes, it becomes the leader. All subsequent modifications to the system must go through the leader.

For example, a client sends a request to the leader, which records the operation in its log (without immediately changing the node’s state).

The leader then replicates this log entry to all followers, which store it in their own logs.

Followers acknowledge receipt, and once the leader receives acknowledgments from a majority, it commits the entry, finally updating the state of the nodes.

After committing, the leader notifies followers that they can apply the update, achieving a consistent system state.

This process is called log replication, a core component of Raft, alongside leader election.

For an interactive demonstration of Raft, visit: http://thesecretlivesofdata.com/raft/

A comprehensive Chinese Raft documentation is available at: https://github.com/maemual/raft-zh_cn/blob/master/raft-zh_cn.md

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Distributed SystemsRaftConsensus AlgorithmPaxosLog Replication
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.