Try
↑ ↓ move↵ openesc close

Interview prep / Raft and consensus

Junior · Raft and consensus · System design interview question

What are the three roles in Raft, and what is a term for?

Sketch your own answer first, then compare it with the one below.

A strong answer

A node is a follower, a candidate or a leader. Followers are passive: they answer requests from leaders and candidates and otherwise wait. A follower that hears nothing for an election timeout becomes a candidate and asks for votes. A candidate that gets a majority becomes the leader, and the leader handles all client writes and sends heartbeats.

A term is a counter that goes up with every election. Each term has at most one leader. Every message carries the sender's term. A node that sees a higher term than its own adopts it and steps down to follower, which is how an old leader learns it has been replaced, and how stale messages from an earlier term are ignored.

Terms are the cluster's logical clock. They are what keeps two leaders from acting at once.

Sources

Learn it by running it

The raft consensus lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms