Raft Consensus Algorithm

Research Depth 65 in the knowledge graph I know this Set as goal
raft consensus leader-based

Core Idea

Raft is a consensus algorithm prioritizing understandability over Paxos through a strong leader approach. A leader is elected via randomized timeouts, appends log entries to followers, and waits for quorum acknowledgment before committing. Followers accept entries only from the current leader and reject stale proposals, ensuring a consistent log order.

Explainer

From your study of the consensus problem, you know the fundamental challenge: getting a group of machines to agree on a sequence of values even when some machines crash. Paxos solved this decades ago, but its specification is notoriously difficult to implement correctly. Raft was designed to solve the same problem with a structure that maps cleanly onto how engineers actually think about systems. It decomposes consensus into three relatively independent subproblems: leader election, log replication, and safety.

Every Raft node is in one of three states: follower, candidate, or leader. Normally, one node is the leader and all others are followers. The leader handles all client requests and tells followers what to write. If a follower stops hearing from the leader (its election timeout expires), it becomes a candidate and starts an election. It increments its term number — a logical clock that increases monotonically — votes for itself, and asks other nodes to vote. Each node votes for at most one candidate per term, and the first candidate to receive votes from a majority becomes the new leader. The randomized timeout is the key trick: because each node's timeout is slightly different, usually only one node times out first, preventing most split votes.

Once elected, the leader accepts client requests, appends each as a new entry in its log, and sends the entry to all followers. When a majority of nodes have written the entry to their logs and acknowledged it, the leader commits the entry and applies it to its state machine. The leader then notifies followers of the commit. If a follower's log falls behind — say it was temporarily disconnected — the leader detects the gap and sends the missing entries. The critical safety property is that if an entry is committed, it will appear in the logs of all future leaders. Raft enforces this by requiring that a candidate can only win an election if its log is at least as up-to-date as a majority of nodes, which guarantees that no committed entry is ever lost.

What makes Raft practical is that its strong-leader design simplifies reasoning about the system. Data flows in only one direction: from leader to followers. There is at most one leader per term. A follower that receives a request from a leader with a stale (lower) term number rejects it. These constraints mean that to understand the system's behavior, you mostly need to understand what the leader does. Real systems like etcd (the coordination backbone of Kubernetes), CockroachDB, and Consul all use Raft or Raft variants, because the algorithm's clarity translates directly into implementations that engineers can audit, debug, and extend with confidence.

Practice Questions 5 questions

Prerequisite Chain

Counting to 10Counting to 20Understanding ZeroThe Number ZeroCounting to FiveOne-to-One CorrespondenceCombining Small Groups Within 5Addition Within 10Addition Within 20Two-Digit Addition Without RegroupingTwo-Digit Addition with RegroupingAddition Within 100Repeated Addition as MultiplicationMultiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Two-Digit by One-Digit DivisionDivision with RemaindersRemainders and Quotients in DivisionDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueReading and Writing DecimalsComparing and Ordering DecimalsAdding and Subtracting DecimalsMultiplying DecimalsDividing DecimalsDividing FractionsMixed Number ArithmeticOrder of OperationsOperators and ExpressionsArithmetic Operators and Operator PrecedenceComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsCombinational Circuit DesignFlip-Flops and LatchesBinary Counters: Design and AnalysisBinary ArithmeticFixed-Point Number RepresentationTwo's Complement RepresentationOverflow and Underflow DetectionBinary Adders: Half-Adders and Full-AddersFull Adder and Carry PropagationCarry Lookahead Adder DesignHalf Adder Circuit DesignMultiplication Circuit DesignSequential Circuit DesignRegisters and Register FilesInstruction Set Architecture (ISA)Kernel Architecture and OS StructureSystem Calls and User/Kernel ModeProcesses and the Process Control BlockLogical Clocks and Event OrderingPaxos Consensus AlgorithmRaft Consensus Algorithm

Longest path: 66 steps · 268 total prerequisite topics

Prerequisites (3)

Leads To (0)

No topics depend on this one yet.