Sudhir Nakka

Distributed Systems - Reaching Consensus, Part 2: Raft

December 29, 2024 (9m ago)6 views

Introduction

This is Part 2 of a two-part series on consensus algorithms. For Part 1 about Paxos, see /2024/paxos.

Raft was introduced with the explicit goal of being more understandable than Paxos while providing equivalent guarantees for building a replicated state machine.

Raft: Simplicity by Design

Motivation and Goals

Raft (Ongaro, Ousterhout, 2013) aims for clarity and practicality. It achieves functionality comparable to Multi-Paxos via a leader-based approach and separation of concerns.

Core Components of Raft

Diagram of Raft showing a Leader sending heartbeats and log entries to Followers
Figure: Raft overview with a single leader replicating log entries to followers via AppendEntries heartbeats.

Raft decomposes the problem into three relatively independent subproblems:

  1. Leader Election: Selecting a single node to coordinate the cluster
  2. Log Replication: Distributing log entries from the leader to followers
  3. Safety: Ensuring the system maintains consistency properties

How Raft Works

Roles and Terms

Time is divided into terms; each term begins with an election. At most one leader can be elected per term.

Leader Election

Log Replication

Safety

Membership Changes (Joint Consensus)

Advantages and Trade-offs of Raft

Advantages:

Trade-offs:

Return to Part 1: Paxos → /2024/paxos