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
- Diego Ongaro, John Ousterhout (2014). In Search of an Understandable Consensus Algorithm.