Intermediate Topic 23 of 51 Distributed Systems & Cloud
Raft
Understandable consensus algorithm using leader election.
How it works
Raft is a consensus algorithm designed to be understandable, equivalent in power to Multi-Paxos. It decomposes the problem into leader election, log replication and safety. Nodes are followers, candidates or leaders; terms act as logical clocks; a follower that hears no heartbeat becomes a candidate and wins with a majority of votes. The leader appends client commands to its log and replicates them via AppendEntries, committing an entry once a majority stores it. Log compaction uses snapshots and membership changes use joint consensus.
Where it is used
etcd, Consul, CockroachDB, TiKV, Kafka's KRaft mode and many replicated services use Raft to keep consistent replicas.
Common pitfall
Implementation details such as randomized election timeouts, persistence before replying, handling of stale leaders and snapshot installation need care. All writes go through one leader, which limits throughput and requires a majority for progress. Network partitions can cause leader changes. Use a mature library and test with fault injection.
Where it fits in the course
Raft is topic 23 of 51 in Distributed Systems & Cloud, rated Intermediate. It follows Paxos. The next topic is Leader Election.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Distributed Systems & Cloud quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Distributed Systems & Cloud quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Raft?
Where do people use Raft?
What is the most common mistake with Raft?
What should I learn before this topic?
How can I practice it?
Is Raft hard to learn?
How long does it take to learn Raft?
Which topics are related to Raft?
What should I study after Raft?
Related topics
- Paxos (Distributed Systems & Cloud)
- Leader Election (Distributed Systems & Cloud)
- Consensus Problem (Distributed Systems & Cloud)
- Two-Phase Commit (Distributed Systems & Cloud)