Why this matters
- Raft is the default answer for "explain consensus" in senior interviews.
- Understanding Raft explains etcd, KRaft, CockroachDB, and ShardPay control-plane behavior.
- ShardPay's shard metadata service and global routing table run on Raft — not the per-account ledger hot path, but critical for correctness.
- You operate Raft clusters daily even if you never implement the algorithm from scratch.
FollowerElection timeout
CandidateRequests votes
LeaderAccepts client writes
Raft in three parts
ShardPay's shard metadata service uses Raft: (1) elect a single leader per term, (2) leader appends client commands to its log and replicates to followers, (3) entries commit once replicated to a majority — then apply to state machine. Clients read routing tables only after commit; stale followers redirect or wait.
Raft components
- Leader election — One leader per term; followers only accept appends from current leader. ShardPay's metadata cluster runs 5 nodes; one leader serves all shard directory updates.
- Log replication — Append-only ordered entries
{term, index, command}. Adding shardledger-257is one log entry; all nodes apply in identical order. - Commit rule — Entry committed when stored on majority. ShardPay's routing service watches committed index before advertising new shard endpoints — prevents clients routing to uncommitted ghosts.
- Safety — Committed entries survive if any majority survives; leader completeness ensures elected leader has all committed entries. ShardPay relies on this for zero-lost shard registrations during node loss.
- etcd / KRaft — Production-hardened Raft implementations. ShardPay metadata runs on etcd 3.5; Kafka topic config in other services uses KRaft — same concepts, different wire format.
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 2 sections
- Log replication flow
- Safety properties and edge cases
Test yourself
Answer these before moving on — recall is what makes it stick.