Basics

Raft fundamentals, formulas, and safety rules.

Start here for roles, terms, majority math, log matching, and the practical reason Raft is easier to explain than Paxos.

Core Model

Raft turns consensus into understandable parts.

Leader

The leader receives writes, appends log entries, and asks followers to replicate them.

Followers

Followers accept valid leader messages and start elections only when heartbeats disappear.

Terms

Terms are logical epochs. Seeing a higher term forces stale leaders and candidates to step down.

Why Raft Matters

Raft is popular because it makes safe distributed agreement teachable and operable.

The original guide explained why Raft matters before diving into edge cases. That context belongs here: Raft is not just an academic algorithm, it is the mental model behind many reliable control planes, databases, schedulers, and replicated metadata systems.

Why Engineers Care

  • It gives a clean model for fault-tolerant writes.
  • It separates leader election, log replication, and safety.
  • It uses majority quorum to prevent unsafe split-brain commits.
  • It makes leadership changes easier to debug than many older consensus explanations.

Why Companies Care

  • Predictable failover improves operational confidence.
  • Committed history survives crashes and leader changes.
  • Strong consistency protects metadata, coordination, and database writes.
  • Availability tradeoffs are explicit instead of hidden.

Why It Became Popular

  • The Raft project emphasizes understandability.
  • It offers Paxos-style safety goals with a clearer teaching structure.
  • It maps naturally to real operational questions: who is leader, who has quorum, and what is committed.
  • Many production systems use Raft directly or rely on Raft-backed components.

Formulas

The math behind quorum and failure tolerance.

Quorum

quorum = floor(N / 2) + 1

A majority must agree before the cluster can safely elect or commit.

Failures

f = floor((N - 1) / 2)

A 5-node cluster can tolerate 2 failed voting members and still keep quorum.

Sizing

N = 2f + 1

To tolerate f failures, use at least 2f + 1 voting members.

Quick Raft Formula Examples

Nodes (N)
Quorum
Failures Tolerated
3
2
1
5
3
2
7
4
3
Formula note: these majority and failure-tolerance rules match the standard Raft quorum model and the common 3, 5, and 7 voter production sizing pattern.

Log Matching Rules

  • Followers reject AppendEntries if the previous index and term do not match.
  • Uncommitted divergent suffixes can be overwritten by the leader.
  • Committed entries must appear in future leaders.

Raft vs Paxos

Raft is designed to be equivalent to Paxos in fault tolerance and performance goals, but decomposes consensus into leader election, log replication, and safety so teams can understand and implement it more easily.

Joint Consensus

Membership changes are handled safely by temporarily requiring overlapping majorities from old and new configurations.

Log Compaction

Real implementations compact old log prefixes into snapshots so followers can catch up without replaying history forever.

Safety Properties

The key properties are election safety, leader append-only, log matching, leader completeness, and state machine safety.