LearnViz CompSci
Home / Learn / Distributed Systems & Cloud / Raft

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

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Distributed Systems & Cloud quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Raft?
Understandable consensus algorithm using leader election. It belongs to Distributed Systems & Cloud and is an intermediate-level topic.
Where do people use Raft?
etcd, Consul, CockroachDB, TiKV, Kafka's KRaft mode and many replicated services use Raft to keep consistent replicas.
What is the most common mistake with Raft?
Implementation details such as randomized election timeouts, persistence before replying, handling of stale leaders and snapshot installation need care.
What should I learn before this topic?
Start with Paxos, the topic just before it in Distributed Systems & Cloud.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Distributed Systems & Cloud quiz.
Is Raft hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn Raft?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Raft?
Paxos, Leader Election, Consensus Problem are closely connected. The full list is in the related topics section of this page.
What should I study after Raft?
Continue with Leader Election, the next topic in Distributed Systems & Cloud.

Related topics