Understanding Distributed Consensus with Raft

Kasun Indrasiri
9 min readApr 5, 2020

Distributed Consensus is one of the hardest problems in the distributed computing domain and there have been many designs and algorithms built for solving it.

In this article, we are going to talk about Raft distributed consensus algorithm which is one of the modern and most popular consensus algorithms out there.

What is Distributed Consensus?

Before we begin the discussion, let’s try to understand what Distributed Consensus means. When we are designing distributed systems, we have to create systems with software applications that are distributed across multiple nodes. It’s is often required for these runtimes running on different nodes to collaboratively make decisions and share data.

The consensus in the real world — a group of people agreeing on something : (source)

So, in distributed consensus, a collection of nodes works as a coherent group and it can survive the failure of some of its members.

Why RAFT?

Raft is a modern, reliable and relatively less complicated distributed consensus algorithm that is frequently used in modern software solutions such as Consul, etcd, RabbitMQ and so on.

Before the inception of Raft, Paxos (designed by Leslie Lamport) was one of the most popular algorithms which are designed for the distributed consensus. Hence many distributed consensus algorithms were either based on Paxos or inspired from it. However, Paxos is known to be a really complex algorithm that is hard to implement to meet its performance and correctness requirements.

One of the main motives behind Raft is to design a distributed consensus algorithm that enhances understandability without compromising performance and correctness. Raft authors(Diego Ongaro and John Ousterhout) argue that Raft is superior to Multi-Paxos protocol as it enhances understandability by maintaining performance and correctness.

Fundamentals

Before diving deep, let’s look at some of the fundamentals of the Raft consensus algorithms.

Raft is based on a leader is driven consensus model where a distinguished leader will be elected and that leader is fully responsible for managing the cluster. The leader manages a replicated log across all the nodes that form the Raft…

Kasun Indrasiri

Sr. Program Manager at Microsoft Azure Messaging Services, O’Reilly Author of gRPC & Cloud Native Patterns, Ex-Architect & PM WSO2 ESB/EI, Speaker @KubeCon