Diego Ongaro
AI-assisted summary of Raft lecture (Raft user study) — original source. Check the original for full context.
Source published:
Key ideas
- Raft structures distributed consensus around an asymmetric, leader-based replicated state machine model that makes forward progress whenever a bare majority of nodes remain reachable. (0:00)
- Protocol complexity is concentrated in leader transitions, which rely on term-based logical clocks, randomized election timeouts, and inductive Log Matching checks to resolve log divergence. (2:11)
- To guarantee safety, leaders are prohibited from committing entries from prior terms solely by counting replicas; they must replicate at least one entry from their current term onto a majority first. (32:26)
- Cluster membership transitions avoid split-brain states by utilizing a two-phase joint consensus protocol (C_old+new) requiring independent agreement from majorities of both configurations. (48:00)
Detailed notes
## Background Published on YouTube by Diego Ongaro on August 15, 2013, this lecture features slides and voice-over by John Ousterhout as part of the Raft User Study. The study was designed to compare how students learn the Raft and Paxos consensus algorithms, serving as an approachable educational introduction to distributed consensus.
## TL;DR John Ousterhout walks through the architecture and design rationale of Raft, an asymmetric, leader-based consensus algorithm designed to replicate state machine logs across clusters. The lecture breaks consensus down into distinct, manageable subproblems: leader election using randomized timeouts, log replication, safety invariants during leader changes, and neutralizing stale leaders via term-based logical clocks. It also covers exact-once client semantics and safe dynamic cluster membership changes using a two-phase joint consensus protocol. Throughout, Ousterhout emphasizes how Raft preserves safety and linearizability even when operating with only a bare majority of active servers.
## Atmosphere & style The presentation has the calm, methodical cadence of a masterclass lecture, delivered with John Ousterhout's characteristic clarity and authoritative precision. The visual rhythm of the slides and deliberate step-by-step breakdowns turn complex distributed systems theory into an intuitive architectural narrative. Listening to the lecture feels rigorous yet remarkably accessible, punctuated by pragmatic engineering skepticism toward single-phase distributed algorithms and a steady focus on why understandable system design matters.
## Bulletin - [00:00](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=0s) Raft structures distributed consensus around an asymmetric, leader-based replicated state machine model that makes forward progress whenever a bare majority of nodes remain reachable. - [02:11](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=131s) Protocol complexity is concentrated in leader transitions, which rely on term-based logical clocks, randomized election timeouts, and inductive Log Matching checks to resolve log divergence. - [32:26](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1946s) To guarantee safety, leaders are prohibited from committing entries from prior terms solely by counting replicas; they must replicate at least one entry from their current term onto a majority first. - [48:00](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2880s) Cluster membership transitions avoid split-brain states by utilizing a two-phase joint consensus protocol (C_old+new) requiring independent agreement from majorities of both configurations.
## Key takeaways - [00:00](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=0s) Raft constructs a replicated state machine by ensuring deterministic, identical log execution across servers as long as a simple majority is operational. - [02:11](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=131s) The protocol operates under a fail-stop model with unreliable networks, explicitly excluding Byzantine faults while tolerating packet loss, delays, and partitions. - [02:11](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=131s) By adopting an asymmetric leader-based design instead of a symmetric model, Raft streamlines normal operations while concentrating complexity in leader replacement. - [05:54](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=354s) Discrete, monotonically increasing terms act as logical clocks, enabling nodes to detect stale leaders and outdated RPCs. - [08:35](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=515s) Inter-server communication is restricted to two idempotent RPCs: RequestVote for elections and AppendEntries for log replication and heartbeats. - [13:59](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=839s) Randomizing election timeouts over a window significantly larger than network broadcast time prevents split-vote deadlocks and ensures election liveness. - [20:02](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1202s) Commit processing is decoupled from stragglers because leaders only wait for acknowledgment from the fastest responding majority before applying entries. - [21:12](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1272s) The Log Matching property acts as an inductive consistency proof, verifying that matching entries at an index and term guarantee identical prior log histories. - [24:43](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1483s) New leaders start serving traffic immediately without a dedicated cleanup phase, progressively overwriting uncommitted follower discrepancies during normal replication. - [30:09](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1809s) The Leader Completeness property is enforced during elections by denying votes to candidates whose logs have an older last term or a shorter length at the same term. - [32:26](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1946s) Leaders cannot commit log entries from previous terms purely by replica counts; committing an entry from the current term is required to secure older entries. - [37:29](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2249s) Log repair is executed by decrementing a follower's nextIndex on rejected AppendEntries until a common log prefix is found, truncating all subsequent divergent entries. - [42:14](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2534s) Deposed leaders attempting replication are neutralized as soon as they encounter any node with a higher term number, forcing an immediate step-down to follower status. - [45:18](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2718s) Linearizable client semantics prevent duplicate execution during network retries by embedding client-assigned unique identifiers within log entries. - [48:00](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2880s) Single-phase cluster configuration changes risk split-brain majorities, requiring a two-phase joint consensus approach to transition safely between configurations. - [54:50](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=3290s) A leader excluded from a new configuration continues managing replication until the C_new entry commits, after which it safely steps down. - [56:32](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=3392s) Raft is architected under the design constraint that correctness must hold with a bare majority operational and without any server having complete global state.
## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=0s) Replicated State Machines and the Role of Consensus
John Ousterhout introduces the Raft consensus algorithm, stating that its primary goal is to identically replicate a log of entries across a group of servers to build a replicated state machine. When an application needs to be made reliable, one standard approach is to execute identical copies of that program across multiple machines and ensure that every instance behaves in the exact same manner. In this context, a state machine simply refers to an application or program that takes inputs and produces corresponding outputs.
```mermaid flowchart LR accTitle: Replicated State Machine Architecture accDescr: Flow diagram showing how a client command is recorded across server logs and executed by state machines.
subgraph ClientLayer["Client"] C["Client"] end
subgraph Cluster["Raft Cluster"] subgraph S1["Server 1 (Leader)"] CM1["Consensus Module"] L1["Log"] SM1["State Machine"] end subgraph S2["Server 2 (Follower)"] CM2["Consensus Module"] L2["Log"] SM2["State Machine"] end subgraph S3["Server 3 (Follower)"] CM3["Consensus Module"] L3["Log"] SM3["State Machine"] end end
C -->|"1. Command X"| CM1 CM1 -->|"2. Append"| L1 CM1 -->|"3. Replicate"| CM2 CM1 -->|"3. Replicate"| CM3 CM2 --> L2 CM3 --> L3 L1 -.->|"4. Safe"| SM1 L2 -.->|"4. Safe"| SM2 L3 -.->|"4. Safe"| SM3 SM1 -->|"5. Result"| C ```
To ensure deterministic execution across machines, the system funnels client commands through an ordered log. A client submits a command (for instance, command $X$) to one of the servers. That command is appended to the local log and forwarded to the other servers to be written into their logs as well. Once safely replicated across the logs, the command is passed to the local state machines for execution, after which the result is returned to the client. As long as every server's log contains the identical sequence of commands in the identical order, their deterministic state machines are guaranteed to produce identical results.
The consensus module is responsible for managing these logs, guaranteeing correct replication, and deciding when an entry is safe to apply to the state machine. Crucially, the protocol does not require every server to be running simultaneously; it guarantees forward progress as long as any majority of the cluster remains operational and capable of communicating.
- In a cluster of 3 servers, the system can tolerate 1 failure, requiring at least 2 servers operational. - In a cluster of 5 servers, the system can tolerate 2 failures, requiring at least 3 servers operational.
---
[02:11](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=131s) Failure Assumptions and Asymmetric (Leader-Based) Consensus
Ousterhout details the explicit failure model under which Raft operates. Servers are assumed to crash in a fail-stop fashion: they may halt execution entirely or pause and resume at a later time, but when executing, they behave correctly. Raft explicitly does not guard against Byzantine faults, meaning servers do not exhibit malicious, corrupted, or arbitrary behaviors. On the network level, communications can be unreliable: messages may be dropped, delayed, duplicated, or delivered out of order, and the network may suffer temporary partitions that later heal.
Historically, consensus algorithms have followed one of two architectural patterns: symmetric (leaderless) or asymmetric (leader-based). In a symmetric scheme, all servers share equal roles and powers; clients can contact any server to append and replicate a log command. In contrast, an asymmetric scheme designates a single leader at any given time to oversee the cluster while the remaining servers operate subserviently to carry out the leader's directions. Clients communicate exclusively with the leader, and only the leader coordinates with follower nodes.
Raft adopts this asymmetric, leader-based model. This choice decomposes consensus into two distinct operational regimes: steady-state normal operation under an active leader, and leader replacement when the active leader fails. Normal operation becomes straightforward because the leader holds unilateral authority, avoiding concurrency conflicts across different machines. However, as Ousterhout observes:
> “All of the complexity in Raft as you'll see comes from leader changes that's particularly true because if a leader crashes it may leave the system in an inconsistent state that the next leader has to clean up.”
Despite this complexity during transitions, leader-based systems are generally more efficient during steady-state execution than leaderless protocols because they avoid resolving mid-stream command conflicts between peers.
---
[04:33](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=273s) Roadmap of the Raft Algorithm
To present the algorithm systematically, Ousterhout outlines the six core topics that comprise Raft's operation:
1. **Leader Election:** How the cluster selects a single leader from among the servers, detects when that leader has failed, and elects a replacement. 2. **Normal Operation:** How the established leader receives client proposals, appends them to its own log, and replicates them across the cluster (the simplest component of Raft). 3. **Leader Changes (Safety and Consistency):** How Raft guarantees safety invariants across transitions, and how a newly elected leader detects and resolves log discrepancies left behind by previous leaders to restore uniform cluster state. 4. **Neutralizing Stale Leaders:** How the protocol prevents deposed or partitioned leaders that are not actually dead from disrupting cluster state or making conflicting decisions. 5. **Client Interaction and Semantics:** How clients discover the leader, survive crashes, and achieve linearizable semantics so that every submitted command executes exactly once. 6. **Cluster Membership Changes:** The mechanism for safely adding or removing physical machines from an active Raft deployment without causing split-brain anomalies.
---
[05:54](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=354s) Server States and Term Numbers
At any point in time, a server in Raft occupies one of three mutually exclusive roles:
- **Leader:** The single server responsible for handling client requests and directing log replication. Raft guarantees that there is at most one active leader per term. - **Follower:** The passive state occupied by most servers during normal operation. Followers initiate no remote procedure calls (RPCs) of their own; they simply listen and respond to incoming requests from leaders and candidates. - **Candidate:** A transient, intermediate state used during an election when nodes campaign to establish a new leader.
Time in Raft is structured into discrete, monotonically increasing terms numbered consecutively ($1, 2, 3, \dots$). Terms act as a logical clock. Each term begins with an election phase where candidates solicit votes. If a candidate wins a majority, it governs as leader for the remainder of that term. However, if votes split evenly and no candidate achieves a majority, the term can conclude without a leader; when this occurs, the servers immediately increment the term counter and initiate a new election.
Every server maintains a persistent variable named `currentTerm` on non-volatile disk storage, ensuring it survives power losses and restarts. This term number is critical for detecting obsolete information across the distributed network. For instance, if an isolated node operating under term 2 receives an RPC from a node operating under term 3, the cluster immediately recognizes that the term 2 node is stale. Obsolete information can thus be discarded without ambiguity.
---
[08:35](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=515s) Protocol Summary and the Two RPC Interfaces
Raft consolidates all inter-server coordination into just two remote procedure call (RPC) interfaces:
- **`RequestVote`:** Initiated exclusively by candidate nodes during an election to gather votes from peers. - **`AppendEntries`:** Initiated exclusively by the active leader during normal operation to replicate log entries and deliver periodic heartbeat signals.
Both RPCs are designed to be idempotent: receiving the same RPC multiple times produces the same outcome without side effects, simplifying the handling of dropped, delayed, or retransmitted network packets.
Ousterhout notes that the complete specification fits on a single slide detailing the exact invariants for each role, the data structures persisted to disk, and the rules governing message handlers. With this foundation established, he transitions to the first detailed phase of the algorithm: leader election, which ensures that at any given moment, at most one valid leader directs the cluster.
[09:47](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=587s) Follower State, Heartbeats, and Election Timeouts
Every server in a Raft cluster initializes in the follower state. In this role, the machine is entirely passive: it never initiates contact on its own and merely responds to incoming remote procedure calls (RPCs) from other nodes. However, a follower only remains passive if it believes an active leader exists. The only way it can verify this is by receiving messages from valid leaders or candidates. Consequently, an active leader must continually communicate with every cluster member to maintain its authority. When a leader has no client commands to distribute, it sends empty `AppendEntries` RPCs, which function strictly as heartbeat messages.
```mermaid flowchart TD accTitle: Raft Server State Transitions accDescr: State transitions between Follower, Candidate, and Leader based on timeouts, votes, and RPCs. F["Follower"] -->|"Election timeout fires<br/>(increments term)"| C["Candidate"] C -->|"Receives majority votes"| L["Leader"] C -->|"Hears from valid leader<br/>or higher term"| F C -->|"Election timeout fires<br/>(split vote)"| C L -->|"Discovers higher term"| F ```
If a follower stops hearing incoming RPCs for a set duration, it concludes that the cluster lacks an operational leader and initiates an election to seek leadership itself. This waiting window is designated as the election timeout. In typical production clusters, this timeout spans between 100 and 500 milliseconds. When an entire cluster powers on simultaneously, every server starts as a follower with no leader present, meaning they all wait out the election timeout before triggering elections.
[11:15](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=675s) The Candidate State and Election Outcomes
When a server decides to begin an election, it starts by incrementing its `currentTerm` counter, establishing a new term higher than any value it previously observed. As John Ousterhout explains, “remember the first thing that happens in every new term is we hold an election.” The node transitions from follower to candidate, aiming to secure votes from a majority of the cluster. It immediately casts its own vote for itself and dispatches `RequestVote` RPCs in parallel to every other server, persistently retrying any unresponsive nodes.
From this point, exactly one of three outcomes occurs: 1. **Majority Achieved:** The candidate successfully secures votes from a majority of servers. It promotes itself to leader and immediately dispatches heartbeat messages to all nodes, which “effectively marks its territory or establishes itself as leader.” 2. **Preempted by a Valid Leader:** Another server simultaneously running for office secures the required majority first. When the candidate receives an RPC from this newly recognized leader, it steps down, returning to the follower state to process commands passively. 3. **Split Vote:** Multiple nodes run simultaneously, dividing the cluster's ballots so that no single candidate achieves a majority. The candidate identifies this condition when its election timeout expires without either a win or a message from a recognized leader. Upon timing out, the candidate increments its term counter once more and initiates a fresh election.
[13:59](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=839s) Safety and Liveness in Leader Elections
A valid consensus election mechanism requires both safety and liveness:
```mermaid flowchart LR accTitle: Raft Randomized Timeout Mechanism accDescr: Randomized election timeouts between T and 2T ensuring staggered wakeups and avoiding split votes. subgraph StaggeredTimeouts["Randomized Timeout Interval: [T, 2T]"] N1["Server 1: Times out first<br/>(e.g., at T)"] N2["Server 2: Still waiting"] N3["Server 3: Still waiting"] end N1 -->|"Sends RequestVote RPCs<br/>(completes within broadcast time)"| N2 N1 -->|"Gains majority before others wake"| N3 ```
- **Safety (At Most One Leader Per Term):** Each server is constrained to cast at most one vote per term, granted strictly on a first-come, first-served basis. To ensure resilience across crashes and reboots, a node persists its vote to stable storage (such as disk) before acknowledging the RPC. Because any winning candidate requires a strict majority, two candidates cannot mathematically win within the same term (e.g., in a 5-node cluster where candidate A earns 3 votes, competing candidate B can acquire at most 2, falling short of a majority). - **Liveness (Guaranteed Progress):** If all servers operated with fixed timeouts, they might repeatedly split ballots across consecutive terms indefinitely. Raft circumvents this by randomizing election timeouts across an interval from $T$ to $2T$, where $T$ represents the base election timeout (e.g., 150–300 ms). Because the spread $T$ is significantly larger than the network broadcast time (the time required to transmit an RPC round-trip across the cluster), the single node that awakens first reliably collects majority ballots before competitors finish waiting.
[16:54](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1014s) Log Structure and Normal Operation
Once a leader is recognized, it enters normal operation to replicate state machine commands across the cluster. Every server maintains an independent copy of the log on stable storage. Logs are structured into sequential entries addressed by an integer index:
| Log Component | Purpose | |:--- |:--- | | **Index** | Monotonically increasing slot number identifying the entry's position in the log. | | **Command** | The raw state machine instruction (e.g., procedure name and arguments) agreed upon by clients and the state machine. | | **Term Number** | The term in which the entry was first created by a leader; increases monotonically through the log. |
Before returning responses to peers or clients, servers must write log changes to disk to withstand unexpected crashes. A log entry is classified as **committed** once it has been durably replicated across a majority of the cluster nodes (for instance, an entry replicated on three nodes in a five-node cluster). John Ousterhout emphasizes the gravity of this milestone: “Raft will guarantee that the entry is durable and sooner or later that entry will be executed by every state machine on every server in the cluster.”
```mermaid flowchart TD accTitle: Client Command Lifecycle During Normal Operation accDescr: End-to-end flow of a client command from proposal to commitment and state machine execution. C["Client"] -->|"1. Submits command"| L["Leader"] L -->|"2. Appends to local log"| L L -->|"3. Parallel AppendEntries RPCs"| F["Followers"] F -->|"4. Successful write ACKs"| L L -->|"5. Majority reached (committed)"| L L -->|"6. Executes on State Machine"| SM["State Machine"] SM -->|"7. Returns execution result"| C ```
During regular execution, a client submits an execution request directly to the leader. The leader appends the raw command to its own log and dispatches parallel `AppendEntries` RPCs to all followers. Once positive confirmations arrive from at least half of the followers—which, combined with the leader's own copy, constitutes a majority—the entry transitions to the committed state. The leader then safely submits the entry to its local state machine and returns the execution result to the client.
[20:02](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1202s) Normal Log Replication and Commitment Performance
Once the leader determines that a particular entry has been committed by virtue of being stored on a majority of servers, it does not send an immediate, dedicated broadcast just to report that fact. Instead, it piggybacks this information onto subsequent `AppendEntries` remote procedure calls (RPCs). Over time, every follower discovers that the entry is officially committed and, upon receiving this notification, promptly executes the corresponding command on its own local state machine.
```mermaid flowchart TD accTitle: AppendEntries RPC and Commit Flow accDescr: Flow diagram showing how a leader replicates entries, receives majority acknowledgments, notifies the client, and updates followers.
subgraph Replication ["Log Replication"] C["Client"] -->|"Command"| L["Leader"] L -->|"AppendEntries RPC"| F1["Fast Follower 1"] L -->|"AppendEntries RPC"| F2["Fast Follower 2"] L -.->|"AppendEntries RPC (retried)"| S["Slow / Crashed Follower"] end
subgraph Commitment ["Majority Consensus"] F1 -->|"Success"| L F2 -->|"Success"| L L -->|"Execute & Return Result"| C L -->|"Subsequent AppendEntries (commitIndex)"| F1 L -->|"Subsequent AppendEntries (commitIndex)"| F2 end ```
Network partitions, crashes, and transient delays are handled seamlessly by the leader's retry policy. If a follower crashes or is painfully slow to respond, the leader continues retrying the `AppendEntries` RPC indefinitely until the follower recovers and responds. Crucially, normal system progress is completely decoupled from these stragglers:
> “So for example one slow server doesn't necessarily slow down the clients because the leader doesn't have to wait for that server.”
Because the leader only requires confirmation from a simple majority—effectively the fastest responding servers in the cluster—it can immediately commit the log entry, execute the client command on its state machine, and return the result to the client without suffering tail latencies.
- Log entries are applied to follower state machines only after the leader notifies them of commitment in later RPCs. - The leader retries `AppendEntries` RPCs indefinitely until unresponsive followers recover. - Client requests finish as soon as the fastest majority responds, ensuring high performance during normal operations.
---
[21:12](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1272s) Log Matching and Consistency Properties
Raft strives to maintain the highest feasible consistency across distributed logs. While transient crashes prevent logs from being perfectly synchronized at every microsecond, Raft enforces rigid structural invariants that hold true at all times:
```mermaid flowchart LR accTitle: Log Matching Induction Property accDescr: Visual depiction of the inductive property where matching entry at prevLogIndex guarantees identical log prefixes.
subgraph Prefix ["Inductive Base: Earlier Entries"] E1["Index 1: Term 1"] E2["Index 2: Term 1"] E3["Index 3: Term 1"] end
subgraph Check ["Consistency Check"] E4["Index 4: Term 2 (prevLogIndex / prevLogTerm)"] end
subgraph New ["Appended"] E5["Index 5: Term 2 (New Entry: jump)"] end
E1 --> E2 --> E3 --> E4 --> E5 ```
1. **Unique Entry Identification:** The combination of an entry's log index and its election term uniquely identifies that entry. If two separate logs contain an entry with the exact same index and term, they are guaranteed to store identical state machine commands. 2. **Identical Log Prefixes:** If two logs share an entry with identical index and term values, then all preceding log entries leading up to that point are guaranteed to match identically across both servers. 3. **Committed Prefix Property:** If an entry at a given index is committed, all preceding log entries are necessarily committed as well. Because committing an entry requires storing it on a majority of machines, and identical entries enforce identical histories, every prior entry must already reside on that same majority.
This consistency invariant is strictly maintained using an inductive check during every `AppendEntries` RPC. Alongside the new log entries being delivered, the leader includes two auxiliary metadata fields: `prevLogIndex` and `prevLogTerm`, representing the index and term of the entry immediately preceding the incoming batch. The receiving follower inspects its own log at `prevLogIndex`. If it does not find an entry with an identical `prevLogTerm`, it unconditionally rejects the RPC.
John Ousterhout explains the mathematical significance of this mechanism:
> “This consistency check is really important and you can think of it kind of like an induction step in the proof of the properties on the preceding slide.”
In an illustrative example where a leader receives the command `jump` and attempts to write it at index 5 with term 2, the leader transmits `prevLogIndex = 4` and `prevLogTerm = 2`. A follower holding term 2 at index 4 accepts the write. Conversely, if a follower has an entry at index 4 from an older term, such as term 1, the check fails, the RPC is rejected, and the log remains unmutated until properly aligned.
---
[24:43](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1483s) Log Discrepancies During Leader Changes
Transitioning to a new leader introduces complications because the outgoing leader may have crashed midway through replicating log entries. Rather than executing an explicit, blocking cleanup phase before accepting new traffic, Raft allows the incoming leader to immediately enter normal operation.
Postponing cleanup to ordinary operation is a pragmatic necessity: when a new leader takes charge, some cluster nodes might still be crashed or partitioned. Halting progress to wait for unreachable servers to clean their state would destroy cluster availability. Instead, Raft adopts a single unifying assumption: the leader's log is always correct, and any discrepancies across followers will be smoothed out over time during normal replication.
To keep technical slides readable when analyzing these chaotic log states, John Ousterhout shifts the notation:
> “First I want to mention I'm going to change my notation a little bit up until now I've shown the commands in log entries but I'm not going to do that anymore since we know that the combination of a log index and the terms stored in an entry is a unique identifier for that entry so from now on I'm just going to show term numbers in the log entries without commands.”
``` Index: 1 2 3 4 5 6 7 -------------------------------------------- Server 1: [1] [1] [1] [4] [4] [5] [5] Server 2: [1] [1] [1] [6] [6] [7] (Leader) Server 3: [1] [1] [1] [6] Server 4: [1] [1] [2] [2] [2] Server 5: [1] [1] [2] [3] [4] ^^^^^^^^^ ^^^^^^^^^^^^^^^^ Committed Expendable / Entries Conflicting ```
A cluster can devolve into significant log fragmentation through a series of partial outages: - Servers 4 and 5 might become leaders throughout terms 2, 3, and 4, appending entries to their local logs without successfully replicating them to any other servers before crashing. - Meanwhile, a network partition could isolate servers 4 and 5 while servers 1, 2, and 3 take turns leading through terms 5, 6, and 7 without being able to reach 4 and 5 to overwrite their mismatched logs. - In such a messy scenario, entries 1 through 3 represent committed entries that have been applied to state machines and must be protected at all costs. - Entries stored after index 3 in this example have never been committed, have never been passed to any state machine, and have produced no observable output for any client. Consequently, these extraneous entries are completely expendable and will eventually be overwritten to match the new leader.
---
[27:49](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1669s) The Safety Requirement and Leader Completeness Property
Whenever conflicting log entries must be discarded to restore cluster-wide consistency, the algorithm must guarantee that committed data is never destroyed. Raft builds its correctness proofs around a fundamental requirement common to all replicated state machine architectures:
> “There's a fundamental overall safety requirement that any system for implementing replicated logs must obey and it's written in red here that once a particular state machine has received a log entry and applied it as a command we must make sure that no other state machine ever applies a different value for that log entry.”
To satisfy this global mandate, Raft specifies a narrower invariant known as the **Leader Completeness Property**: once a leader decides an entry is committed, that entry is guaranteed to be present in the logs of all future leaders for their entire lifetimes.
The inductive reasoning linking this property directly to system safety is straightforward: 1. Leaders operate in an append-only fashion and never overwrite or truncate their own log entries. 2. An entry can only be committed if it exists in the leader's log; therefore, competing values cannot be committed at that same index. 3. State machines only apply entries that have been verified as committed.
Because the basic protocol described up to this point does not naturally guarantee Leader Completeness, Raft introduces two crucial modifications to the algorithm:
- **Election Restrictions:** The leader election process is restricted so that a candidate is denied votes if its log does not contain all committed entries (preventing an out-of-date candidate from winning). - **Modified Commitment Rules:** The definition of when an entry is committed is refined. Leaders are prohibited from committing entries from previous terms merely by counting replicas; they must delay commitment until an entry from their current term can be safely committed.
[30:09](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1809s) The Leader Election Restriction and Log Comparison
Ensuring that a newly elected leader holds every committed log entry poses a fundamental challenge: during a leadership transition, servers cannot directly tell which entries are committed. John Ousterhout illustrates this using a three-server cluster where one machine is unavailable. Looking solely at the surviving servers, it is impossible to know whether an un-replicated entry (such as entry 5) was committed, because commitment depends on whether that entry was successfully stored on the unreachable server before it failed. To solve this dilemma, Raft avoids trying to determine commitment directly at election time. Instead, the protocol ensures that the candidate winning the election possesses the log most likely to contain all committed entries, turning what seems like an intractable mystery into a strict invariant.
```mermaid flowchart TD accTitle: Raft Log Comparison Rule for Vote Requests accDescr: Decision flow when a follower compares its log to a candidate requesting a vote.
subgraph CandidateLog["Candidate Request"] C["Candidate: lastLogTerm, lastLogIndex"] end
subgraph VoterDecision["Voter Evaluation"] CheckTerm{"Voter's lastLogTerm > Candidate's lastLogTerm?"} CheckLength{"Terms equal, but Voter's log longer?"} Deny["Deny Vote (Voter is more complete)"] Allow["Vote Permitted (Candidate is as up-to-date)"] end
C --> CheckTerm CheckTerm -- "Yes" --> Deny CheckTerm -- "No" --> CheckLength CheckLength -- "Yes" --> Deny CheckLength -- "No" --> Allow ```
The candidate’s log completeness is evaluated during the RequestVote RPC using only two pieces of metadata: the index of the candidate's last log entry and the term from that entry. Because an entry's index and term uniquely determine the entire log preceding it, the voter needs no additional history to assess the candidate. The voting server compares these values against its own log and denies its vote whenever its own log is “more complete.” Ousterhout explains the precise conditions governing this comparison:
> “Now to make this specific, we define this to mean that if the last term in the voting server log is greater than the last term in the candidate's log, then the voter's log is more complete, deny the vote; or if the terms match and the voting log is longer than the candidate's log, then again the voter's log is more complete, and so we deny the vote.”
Because a winning candidate must secure votes from a majority of the cluster, this rule guarantees that the elected leader has the most complete log among that majority, preventing any node with an out-of-date history from seizing control.
- Candidates only transmit their `lastLogIndex` and `lastLogTerm` in vote requests. - A voter denies its vote if its own `lastLogTerm` is strictly greater than the candidate’s `lastLogTerm`. - If the last terms are identical, the voter denies its vote if its log has more entries than the candidate’s log. - Any server winning an election is mathematically guaranteed to contain all entries up to the most complete log within that voting majority.
---
[32:26](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=1946s) Safety: Committing Entries in Current vs. Prior Terms
To verify safety, Ousterhout analyzes what happens immediately after a leader concludes an entry is committed, distinguishing between two scenarios: committing an entry created in the current term versus an entry inherited from an earlier term. In the first case, a leader in term 2 replicates entry 4 onto server 3, establishing a majority replica set across servers 1, 2, and 3. Here, the entry is immediately safe. Server 5 cannot win a future election because its last term is older than the rest of the cluster, and server 4 cannot win because its log is too short to secure a majority. The next leader must come from servers 1, 2, or 3, each of which already contains entry 4.
```mermaid flowchart LR accTitle: Leader Commit Safety Requirement accDescr: Steps required for a leader to safely commit prior-term entries.
subgraph PastTerm["Earlier Term Entry"] P["Replicate Prior Term Entry to Majority"] end
subgraph CurrentTerm["Current Term Entry"] C["Replicate at Least One Current Term Entry to Majority"] end
subgraph SafeCommit["Commit Action"] S["Safely Commit Both Current and Prior Entries"] end
P --> C --> S ```
The second scenario introduces a subtle and dangerous failure mode. Suppose a leader from term 2 replicates an entry to two nodes before losing leadership. A leader in term 3 creates uncommitted entries and crashes. Later, a leader in term 4 attempts to repair the logs by replicating that old term 2 entry onto a majority (server 3). Even though this term 2 entry now resides on a majority of nodes, it is not safe. If the term 4 leader crashes before creating entries in term 4, server 5 could win an election with votes from servers 2, 3, and 4, because its last entry from term 3 has a higher term than theirs. Once elected, server 5 would overwrite the term 2 entry across the cluster.
To eliminate this vulnerability, Raft refines the commitment invariant:
> “In order to guarantee safety, we have to add another rule, which is that in addition, the leader must be able to see that at least one of the entries from its term, from the current term, is also stored on a majority of servers.”
Once the term 4 leader replicates an entry from term 4 to a majority, server 5 can no longer win an election, making both the old term 2 entry and the new term 4 entry permanently safe from being overwritten.
- An entry from the leader's current term is safe as soon as it is stored on a majority of servers. - A leader cannot commit an entry from an older term purely by counting replicas; it must commit an entry from its own term first. - Replicating an entry from the current term to a majority protects earlier entries by advancing the cluster's terms beyond the reach of outdated candidates. - Combined with election restrictions, this commitment rule guarantees that every future leader will preserve all committed log entries.
---
[37:29](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2249s) Restoring Log Consistency and the nextIndex Mechanism
Once leader safety is established, the leader must force all follower logs to match its own. Follower logs can deviate from the leader in multiple ways: followers may lack entries that the leader has (e.g., followers missing tail entries), or they may hold extraneous uncommitted entries created by deposed leaders from previous terms (such as remnants from terms 2, 3, 6, or 7). The leader's objective is straightforward: strip away all extraneous entries from follower logs and backfill every missing entry.
```mermaid flowchart TD accTitle: Log Reconciliation via nextIndex Retries accDescr: Flowchart illustrating how a leader decrements nextIndex until finding a matching entry.
Init["Leader sets nextIndex = lastLogIndex + 1"] Send["Send AppendEntries with prevLogIndex and prevLogTerm"] Check{"Follower log matches at prevLogIndex?"} Decrement["Leader decrements nextIndex by 1"] Append["Follower overwrites discrepancies and appends missing entries"]
Init --> Send Send --> Check Check -- "No (Reject)" --> Decrement Decrement --> Send Check -- "Yes (Accept)" --> Append ```
To manage this reconciliation, the leader maintains a state variable for each follower termed `nextIndex`. This represents the log index of the next entry the leader intends to transmit to that specific follower. Upon taking office, the leader initializes every follower's `nextIndex` to the index immediately following the leader's last log entry (for instance, setting `nextIndex` to 11 if the leader's last entry is at index 10).
Discrepancies are discovered using the standard `AppendEntries` consistency check. Whenever the leader contacts a follower—often via the very first heartbeat after election—it includes the index and term of the entry immediately preceding `nextIndex` (e.g., index 10, term 6). If the follower lacks a matching entry at that index and term, it rejects the request. The leader reacts systematically to each failure:
> “When the leader sees this rejection, its response is very simple: it just reduces nextIndex by one, so it will drop index back to 10 and then we'll try again.”
This probe-and-decrement process repeats, stepping backward entry by entry (from 10 to 9, 8, 7, etc.) until `nextIndex` reaches a point where the logs agree (such as index 5 matching entry 4). Once the follower accepts the request, the consistency check succeeds, enabling the follower to append the leader's entries, discard any conflicting future entries, and synchronize completely with the leader.
- `nextIndex` tracks the next entry the leader plans to replicate to a specific follower. - It is initialized to `lastLogIndex + 1` for all followers upon a leader's election. - Heartbeats function identically to regular `AppendEntries` RPCs with respect to log consistency checks, even when they carry no payload entries. - Each failed `AppendEntries` consistency check causes the leader to decrement `nextIndex` by 1 and retry until a common point of agreement is established.
[40:40](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2440s) Log Repair and Truncation During Leader Changes
When bringing a follower's log into alignment with the leader, the leader repeatedly decrements `nextIndex` whenever an `AppendEntries` consistency check fails. In an extreme example where a follower's log diverges early on, the check fails at index 11, causing the leader to back up step by step through indices 10, 9, 8, 7, 6, and 5, until `nextIndex` eventually reaches 4. At that position, the preceding entry at log index 3 (with term 1) finally matches between leader and follower, allowing the leader to begin appending new entries to fill in the missing log slots.
```mermaid flowchart LR accTitle: Raft Log Truncation on Conflicting Append accDescr: Diagram showing how a follower truncates its log upon receiving a new matching entry that conflicts with existing entries. subgraph FollowerLog["Follower Log State"] direction TB E3["Slot 3: Term 1 (Match)"] E4["Slot 4: Overwritten"] E5["Slot 5: Truncated"] E6["Slot 6: Truncated"] end E3 --> E4 E4 -.->|Drop remaining| E5 E5 -.-> E6 ```
Crucially, log repair does not simply patch individual slots in place; it removes invalid divergent histories. Whenever a follower receives an entry that replaces an inconsistent entry in its log, it truncates its log, deleting that entry and every subsequent entry that follows it. For instance, if the leader transmits an entry for slot 4 to overwrite a conflicting entry from term 2, the follower overwrites slot 4 and immediately discards all remaining entries after slot 4. As John Ousterhout explains, “We know any entry after an extraneous entry is also extraneous.”
Summarizing the overarching problem of leader changes, Ousterhout points out that there are two core issues: - **System safety**: Guaranteeing correct leader election criteria and defining strict rules for when log entries can be safely considered committed. - **Log alignment**: Once a new leader is elected, making all follower logs match its own, achieved entirely through the `AppendEntries` consistency check.
---
[42:14](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2534s) Neutralizing Deposed Leaders with Terms
The fourth major component of the Raft protocol addresses deposed leaders that are unaware they have lost power. If a network partition isolates a leader from the remainder of the cluster, the remaining majority will wait out the election timeout and elect a new leader. If the old leader subsequently reconnects, it remains ignorant of the recent election and continues attempting to act as the legitimate leader. It may accept incoming commands from clients, record them into its local log, and attempt to replicate them across other nodes.
```mermaid flowchart TD accTitle: RPC Term Check and Role Demotion accDescr: Flowchart illustrating how mismatched terms in RPC messages force stale servers to step down. A["RPC Transmitted (Contains Sender's Term)"] --> B{"Compare Sender Term vs. Receiver Term"} B -->|"Sender Term < Receiver Term"| C["Receiver Rejects RPC and Sends Reply with Current Term"] C --> D["Sender Steps Down to Follower & Updates Term"] B -->|"Sender Term > Receiver Term"| E["Receiver Steps Down to Follower & Updates Term"] E --> F["Receiver Processes RPC Normally"] B -->|"Terms Match"| G["Process RPC Normally"] ```
To eliminate split-brain hazards, Raft uses terms to detect and neutralize stale servers across all communication channels: - Every remote procedure call (RPC) includes the sender's current term. - Upon receiving an RPC, the receiver compares the incoming term to its own local term. - If the sender’s term is older than the receiver's, the sender is stale. The receiver immediately rejects the RPC, refuses to execute it, and returns its own higher term in the response. Upon observing the higher term, the old leader realizes it is out of date, immediately steps down to become a follower, and updates its local term. - Conversely, if the receiver discovers that its own term is older than the sender's, the receiver steps down (if it was acting as a leader or candidate), updates its term to match the sender's, and proceeds to handle the RPC normally without rejecting it.
Because candidate servers must solicit votes from a majority of the cluster during elections—broadcasting their proposed term in each `RequestVote` RPC—a majority of servers have their terms raised before any new leader is successfully elected. Consequently, an old leader isolated on the minority side can never replicate a new log entry to a majority: contacting any node in that updated majority will instantly trigger a term mismatch. As John Ousterhout emphasizes, “Once an election is complete there's no way that that deposed server can actually receive a new log entry and write it to a majority of the cluster because to do that it would have to contact at least one of those servers that has the new term and when it does that the term mismatch will be discovered and that old leader will then step down.”
---
[45:18](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2718s) Client Interaction and Exactly-Once Semantics
The fifth part of Raft covers client interactions. In standard operation, a client sends its commands directly to the leader and waits for a response. If a client does not know which server is the current leader, it simply contacts any arbitrary cluster node. If that node is a follower, it redirects the client by identifying the current leader. The leader does not respond to the client immediately upon receiving the command; it logs the command, replicates it until it is committed on a majority of server disks, applies the command to its state machine, and only then returns the execution result to the client.
```mermaid flowchart TD accTitle: Exactly-Once Client Command Processing accDescr: Logic flow of how a Raft leader handles unique command IDs to prevent duplicate execution upon retries. A["Client sends Command with Unique ID"] --> B{"Leader checks: Is ID already in log?"} B -->|"No (New Command)"| C["Append to Log, Replicate, and Commit"] C --> D["Execute in State Machine"] D --> E["Return New Result to Client"] B -->|"Yes (Duplicate Retry)"| F["Ignore New Command"] F --> G["Wait for / Fetch Result of Prior Execution"] G --> E ```
When a leader crashes or an RPC times out before the client receives a response, the client must reissue the command to another server until it discovers the new leader. This retry mechanism guarantees that commands will eventually execute, but it introduces the hazard of duplicate execution if a leader crashes after applying a command to its state machine but before sending the client its reply. To guarantee exactly-once semantics and achieve linearizability: - The client assigns a globally unique identifier to every command prior to sending. - The leader embeds this unique ID into the corresponding log entry before appending. - Before accepting and appending a newly arrived command, the leader inspects its log to see whether that ID has already been recorded. - If the ID is detected, the leader recognizes the command as a duplicate, ignores the new request, waits for the prior entry to be executed by the state machine (if it has not finished already), and returns the previously computed result.
---
[48:00](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2880s) Cluster Configuration Changes and Split-Brain Risks
The sixth and final phase of Raft handles system configuration changes, which involve modifying the set of participating servers, their node IDs, and their network addresses. Configuration management is vital because the list of servers determines what constitutes a majority quorum for leader elections and entry commitments. System administrators must be able to replace failed hardware or adjust replication factors dynamically without bringing the system offline.
```mermaid flowchart TD accTitle: Split-Brain Risk in Direct Configuration Switching accDescr: Diagram illustrating how naive direct switching from three servers to five servers allows overlapping independent majorities. subgraph OldConfig["Old Configuration (3 Servers)"] S1["Server 1 (Old)"] S2["Server 2 (Old)"] S1 --- S2 MajOld["Majority of Old = 2 servers\n(Servers 1 & 2 can elect/commit)"] end subgraph NewConfig["New Configuration (5 Servers)"] S3["Server 3 (New)"] S4["Server 4 (New)"] S5["Server 5 (New)"] S3 --- S4 --- S5 MajNew["Majority of New = 3 servers\n(Servers 3, 4, & 5 can elect/commit)"] end MajOld -.->|"Conflicting Decisions at Same Time"| MajNew ```
A naive, direct switch from an old configuration ($C_{\text{old}}$) to a new configuration ($C_{\text{new}}$) is inherently unsafe. Because cluster machines cannot switch configurations simultaneously in real time, nodes change over at slightly different moments, creating windows where two conflicting majorities exist concurrently: - Suppose a three-server cluster is expanded to five servers. - If servers switch independently, Server 1 and Server 2 can remain in the old three-node configuration and make autonomous decisions, because two servers constitute a majority of three. - At the exact same moment, Servers 3, 4, and 5 might have switched to the new five-node configuration, where three servers constitute a majority of five. - Both disjoint subsets could independently elect different leaders and commit conflicting entries to the identical log slot.
Ousterhout underscores that multi-node consensus cannot be updated atomically in a single round: “If anybody ever tells you that they think they can make a distributed decision in a single phase, you should question them pretty seriously because either they're wrong or they've discovered something that everybody else in the world doesn't know yet.”
To resolve this, Raft uses a two-phase protocol centered around an intermediate stage called *joint consensus*. During joint consensus, the cluster configuration encompasses the union of all nodes in both $C_{\text{old}}$ and $C_{\text{new}}$, requiring separate, independent majorities from both the old configuration and the new configuration to agree on any decision, including elections and log entry commitment.
[50:46](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=3046s) Joint Consensus and the Two-Phase Configuration Change
To safely change cluster membership, the algorithm requires separate agreements from both the old configuration and the new configuration. John Ousterhout walks through how this transition works over time. The system begins in an existing configuration denoted as $C_{\text{old}}$. A configuration change is initiated when a client submits a request to the leader, just like any standard state machine operation. Upon receiving the request, the leader creates a special log entry describing the joint configuration, denoted as $C_{\text{old}+\text{new}}$. The leader appends this entry to its own log and replicates it across the cluster using standard `AppendEntries` RPCs.
```mermaid flowchart TD accTitle: Raft Joint Consensus Timeline accDescr: Timeline of configuration transitions from C_old through C_old+new to C_new
subgraph Phase1["1. Old Configuration"] COld["C_old in effect"] end
subgraph Phase2["2. Joint Consensus Entry"] ColdNewLog["Leader logs C_old+new"] ColdNewCommit["C_old+new committed"] end
subgraph Phase3["3. Final Configuration"] CnewLog["Leader logs C_new"] CnewCommit["C_new committed"] end
COld --> ColdNewLog ColdNewLog -->|"Decisions need majorities of both C_old and C_new"| ColdNewCommit ColdNewCommit --> CnewLog CnewLog -->|"Decisions require majority of C_new"| CnewCommit ```
The critical rule distinguishing configuration entries from normal log entries is their timing: configuration changes take effect immediately. As soon as any server appends a configuration entry to its log, it immediately begins living by that configuration; it does not wait for the entry to be committed before applying it. Once the leader places $C_{\text{old}+\text{new}}$ in its log, it governs all subsequent decisions by joint consensus. This means any log entry must be acknowledged by a majority of the machines in $C_{\text{old}}$ and a majority of the machines in $C_{\text{new}}$ to become committed.
Before $C_{\text{old}+\text{new}}$ is committed, if the leader crashes, another server operating purely under $C_{\text{old}}$ might be elected. However, once $C_{\text{old}+\text{new}}$ achieves commitment, it is impossible for any node to make a decision purely based on $C_{\text{old}}$. Because any newly elected leader must contain all committed entries, every future leader is guaranteed to have $C_{\text{old}+\text{new}}$ in its log and enforce joint consensus. Once the joint consensus entry is committed, the leader writes and replicates a final configuration entry, $C_{\text{new}}$. After $C_{\text{new}}$ is committed, all future decisions rely strictly on the new configuration.
- A client initiates cluster membership changes via standard leader RPC requests. - Configuration entries take effect immediately upon being logged, prior to commitment. - Joint consensus requires independent majorities from both configurations: - A majority of the old cluster configuration ($C_{\text{old}}$) - A majority of the new cluster configuration ($C_{\text{new}}$) - The phases ensure non-overlapping windows of unilateral authority: $C_{\text{old}}$ and $C_{\text{new}}$ can never make independent decisions at the same time.
---
[54:50](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=3290s) The Fundamental Nature of Two-Phase Distributed Agreement
Ousterhout highlights a foundational truth of distributed systems: changing membership requires two distinct phases to prevent split-brain outcomes. As he puts it:
> “If anybody comes to you with a distributed agreement algorithm and they claim it works in a single phase, you should be very skeptical because either they're mistaken or they've discovered something really important and new that none of the rest of us know.”
During the configuration changeover, a server from either configuration can serve as the leader. This introduces a tricky edge case: what happens if the current leader is not a member of $C_{\text{new}}$? Such a leader cannot govern the cluster indefinitely. In Raft, the leader continues to manage replication through the transition and steps down at the exact point when the $C_{\text{new}}$ entry is committed. Once the leader steps down, the remaining follower nodes time out, initiate an election, and choose a new leader drawn exclusively from $C_{\text{new}}$.
```mermaid flowchart LR accTitle: Stepping Down of a Leader Not in C_new accDescr: Sequence showing how an excluded leader steps down once C_new commits
A["Leader replicates C_new<br/>(Leader not in C_new)"] --> B["C_new reaches commit point"] B --> C["Old leader steps down"] C --> D["Followers time out"] D --> E["New leader elected from C_new"] ```
- Any distributed agreement protocol inherently demands two phases to safely adjust membership. - A leader omitted from $C_{\text{new}}$ continues orchestrating the cluster until $C_{\text{new}}$ is committed. - Followers detect the old leader stepping down via election timeouts, prompting an election that selects a leader exclusively from $C_{\text{new}}$.
---
[56:32](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=3392s) Summary of the Six Raft Subproblems and Concluding Insights
Ousterhout concludes the lecture by summarizing the six core building blocks that make up the complete Raft consensus algorithm:
1. **Leader Election:** Guarantees that at most one leader can be active in any given term. 2. **Normal Operation:** Handles client request reception, log appending, and cluster-wide replication, underpinned by the `AppendEntries` consistency check that enforces log integrity and provides the mechanism to heal inconsistencies. 3. **Leader Changeovers:** Solves safety guarantees to ensure committed log entries persist forever, while forcing follower logs into lockstep with the new leader. 4. **Neutralizing Deposed Leaders:** Prevents stale, disconnected leaders from disrupting the cluster when reconnecting. 5. **Client Interaction:** Manages linearizable semantics, session tracking, and survival across server crashes. 6. **Configuration Changes:** Implements safe, automatic cluster membership changes using joint consensus.
In closing, Ousterhout emphasizes the overarching constraint shaping the entire design:
> “The key element of this algorithm is that the system has to work perfectly even if just a bare majority of the servers are up, which means it can't ever depend on having complete information or knowledge of what's going on.”
Because offline servers might harbor critical, unobserved state, Raft's safety mechanisms must ensure safe operation even under incomplete knowledge, requiring only a simple majority to achieve consensus.
## Notable quotes > [48:00](https://www.youtube.com/watch?v=YbZ3zDzDnrw&t=2880s) If anybody ever tells you that they think they can make a distributed decision in a single phase, you should question them pretty seriously because either they're wrong or they've discovered something that everybody else in the world doesn't know yet. — John Ousterhout
## Mentioned John Ousterhout, Diego Ongaro, Raft, Paxos
## Video description This lecture is part of the Raft User Study, an experiment to compare how students learn the Raft and Paxos consensus algorithms. It's a useful introduction for anyone learning Raft. Slides and voice-over by John Ousterhout.
Slides, more info, etc: https://raft.github.io/ and https://ramcloud.stanford.edu/~ongaro/userstudy/
Corresponding Paxos video: http://youtu.be/JEpsBg0AO6o
[Source](https://www.youtube.com/watch?v=YbZ3zDzDnrw)