Raft (algorithm): Difference between revisions

Content deleted Content added
m Spelling, per context.
Pdkaye (talk | contribs)
Line 12:
When the existing leader fails or when you start your algorithm, a new leader needs to be elected.
 
In this case, a new ''term'' starts in the cluster. A term is an arbitrary period of time on the server onduring which noa new leader needs to be elected. Each term starts with a leader election. If the election is completed successfully (i. e. a single leader is elected) the term keeps going with normal operations orchestrated by the new leader. If the election is a failure, a new term starts, with a new election.
 
A leader election is started by a ''candidate'' server. A server becomes a candidate if it receives no communication by the leader over a period called the ''election timeout'', so it assumes there is no acting leader anymore. It starts the election by increasing the term counter, voting for itself as new leader, and sending a message to all other servers requesting their vote. A server will vote only once per term, on a first-come-first-served basis. If a candidate receives a message from another server with a term number at least as large as the candidate's current term, then its election is defeated and the candidate changes into a follower and recognizerecognizes the leader as legitimate. If a candidate receives a majority of votes, then it becomes the new leader. If neither happens, e.g., because of a split vote, then a new term starts, and a new election begins.<ref name="paper" />
 
Raft uses randomized election timeout to ensure that split votes problem are resolved quickly. This should reduce the chance of a split vote because servers won't become candidates at the same time : a single server will timeout, win the election, then become leader and sends heartbeat messages to other servers before any of the followers can become candidates.<ref name="paper" />