A short introduction about Raft: a distributed consensus algorithm

tzJacky
3 min readApr 13, 2021
Photo by Kees Streefkerk on Unsplash

What is a distributed consensus algorithm?

In a distributed system, there are many nodes in one cluster. We need to have an algorithm to ensure a consensus of data among those nodes or reach an agreement on a proposal. The algorithm is called a distributed consensus algorithm.

What is Raft?

Raft is an understandable distributed consensus algorithm that is easy to explain how it works. On the contrary, Paxos, another distributed consensus algorithm that was first submitted in 1989, is hard to understand and implement. I’m going to give a short introduction about Raft.

Raft basics

States

The Raft has three states: Leader, Follower, and Candidate. Leader handles all client requests, replicates logs to followers, and there is only one leader at the same time. The Candidate is a transition state from Follower to Leader and is used to elect a new Leader. The Follower is passive and responds to requests from leaders and candidates.

Term

Raft divides time into terms of arbitrary length. Each term begins with an election. The term number increases monotonically over time, which is used to detect if a leader is…

--

--