---
title: "Raft: Leader Election and Log Replication"
description: "One consensus algorithm end to end. A term-numbered election picks a single leader, the leader appends entries to its followers, and an entry is committed once a majority holds it. Every rule in the p"
canonical: https://lightmysky.com/learn/computing/raft-leader-election-and-log-replication-mt_JdHtEJSPSP
source: https://lightmysky.com/learn/computing/raft-leader-election-and-log-replication-mt_JdHtEJSPSP.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Raft: Leader Election and Log Replication

One consensus algorithm end to end. A term-numbered election picks a single leader, the leader appends entries to its followers, and an entry is committed once a majority holds it. Every rule in the protocol exists to stop one specific bad history.

Subject: Computing · Area: Networks & Security · Ages 22 to 23
Page: https://lightmysky.com/learn/computing/raft-leader-election-and-log-replication-mt_JdHtEJSPSP

## Ready when they can

- Walk an election through a term change and say why two leaders cannot both win one term
- Say what commitment means here and why a majority is the threshold
- Take one rule of the protocol and name the history it prevents

## Lesson: Raft elects, then replicates

Raft numbers every election with a term. Each node votes once per term, so two candidates cannot both win one term: two majorities share a voter, and that voter only votes once. The winner becomes the single leader.

**Example.** The leader takes client writes, appends them to its log, and sends each entry to its followers. An entry is committed once a majority holds it. If the leader fails, the new leader is elected and every committed entry survives, because any majority includes a copy.

Every rule blocks one specific bad history. Voting once per term blocks two leaders deciding differently. Requiring an up-to-date log for new leaders blocks the loss of committed entries.

**Tip.** Walk any failure by asking one question: was the entry on a majority. If yes, it survives. If no, it may be gone.

**Recap.** One leader per term appends entries, majorities commit them, and committed means surviving.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Impossibility Under Asynchrony: What Consensus Cannot Promise](https://lightmysky.com/learn/computing/impossibility-under-asynchrony-what-consensus-cannot-promise-mt_le54TNOeiR)

## Opens up

- [Quorums, Leases and Changing the Membership](https://lightmysky.com/learn/computing/quorums-leases-and-changing-the-membership-mt_2uRmRqFutD)
