Loading
0x50Lesson 6 of 9

Coordinate with leaders and consensus

Learn what consensus solves and why leader leases need care.

14 min 5-question quiz
By the end of this lesson you can
  • Describe consensus, leader election, and split-brain risk at a high level.

Consensus protocols let nodes agree on an ordered sequence of decisions despite some failures, under specific assumptions such as a majority being able to communicate. Systems often elect a leader to simplify writes, but election alone is not enough: an old leader may still believe it is in charge after a partition. Terms, quorum checks, and fencing tokens help reject stale leaders. Consensus does not make a system immune to arbitrary failures or network delay.

Raft and Paxos are families of consensus protocols with detailed safety and liveness rules; production systems must implement the whole protocol rather than rely on a majority check alone.

Practice: split a cluster

Try it

Up to 15 XP

Who’s in charge during a partition?

Click a node to move it across the network split, and watch what each side can do.

  1. Start with 3 nodes against 2. What does the old leader believe?
  2. Move the old leader to the majority side.
  3. Switch to 4 nodes and split them 2 and 2. Why does nobody win?
Cluster size (a majority is 3)

One side of the split

Has a majority: can commit writes.

These nodes elect a new leader in a higher term.

Other side of the split

No majority: can’t commit writes.

The old leader still thinks it’s in charge, but nothing it writes can commit.

Click a node to move it to the other side.

Two nodes believe they’re the leader. It’s safe only because the old leader can’t reach a majority, and fencing tokens stop it from touching shared resources.

Practice: stop a stale leader

Try it

Up to 15 XP

How a fencing token works

A leader was paused for a long time and doesn’t know it was replaced. Follow what happens when it wakes up.

Message 1 of 5Predicted 0/0
Old leader
New leader
Storage

Key takeaways

  • Consensus depends on explicit assumptions about failures and communication.

  • Leader election needs protection against stale leaders.

  • A majority check alone is not a consensus algorithm.

Lesson quiz

5 questions · pass with 4 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…