Skip to content
StackDecode
System Design
6. Distributed Systems FundamentalsAnimated

Consensus Algorithms

Getting nodes to agree on one value despite failures.

The idea

Paxos and Raft let a majority agree and remember decisions even when some nodes crash.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

followerT0 L0followerT0 L0followerT0 L0followerT0 L0followerT0 L0
  • leader
  • candidate
  • follower
  • crashed

Five servers start as followers. Each waits for a heartbeat from a leader; if none arrives before a random timeout, it will stand for election.

1/10

Raft guarantees at most one leader per term and never loses committed entries.

Step by step

  1. 1Propose a value
  2. 2Gather a majority
  3. 3Commit
  4. 4Apply in order

Where it is used

Replicated logs and configuration.

Watch out for

Needs a majority alive, and adds latency.

Related