← Questions

Compare Paxos and Raft

0
UberSystem designLast asked Sep 2025

A system design interview question asked in Uber's system design round, last asked Sep 2025. It tests consensus, distributed systems and replication.

Explain how Paxos and Raft reach consensus on a replicated log, and compare them: leader election, quorum requirements, log replication, membership changes and behavior under network partitions. Walk through failure scenarios (a leader crash, delayed messages, a node losing its disk) and how each protocol recovers. Then, for a new service whose team values operational simplicity and debuggability, choose one and justify the trade-offs.

Requirements

  • Functional: describe each protocol well enough to trace a write from client to commit, including the messages exchanged.
  • Functional: compare them point by point on the five areas above.
  • Functional: walk through each failure scenario for both protocols, step by step.
  • Non-functional (for the recommendation): a small team must run, debug and reason about the service; correctness under partitions is required; latency and throughput needs are moderate.

Clarifying questions

  • Is "Paxos" single-decree Paxos, Multi-Paxos, or a family including variants such as EPaxos?
  • What does the new service replicate: configuration, a lock service, a database log?
  • How many replicas and how many regions?
  • Is an existing library acceptable (etcd's Raft, a Paxos implementation), or must the team build one?

What a strong answer covers

  • Single-decree Paxos: proposers, acceptors, ballot numbers, the prepare/promise and accept/accepted phases, and why a majority quorum makes any two quorums intersect. Multi-Paxos with a stable leader skipping phase 1.
  • Raft: terms, randomized election timeouts, votes granted only to candidates with an up-to-date log, AppendEntries with the previous index and term for consistency, commit once a majority stores an entry from the current term.
  • Differences: Raft's strong leader and log-matching property against Paxos's per-slot agreement and possible holes in the log; Raft's specified membership change (joint consensus or one server at a time) against Paxos's loosely specified reconfiguration.
  • Partitions: a minority side cannot commit in either protocol; a stale leader in Raft steps down on seeing a higher term; linearizable reads need a lease or a read-index round.
  • Failures: leader crash and a new election; delayed messages rejected by term or ballot; disk loss is the dangerous one, since a node that forgets its promises or votes can break safety, so it must rejoin as a new member.
  • A decision, likely Raft for understandability, tooling and mature libraries, with what you give up.

Follow-ups

  • Two Raft nodes both think they are leader for a moment. Why is that safe?
  • How do you add a fifth replica without losing availability?
  • Where would you choose a leaderless protocol instead, and why?
  • How do snapshots and log compaction work in Raft?

Where it's asked

What it tests

consensus · distributed systems · replication

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing