Raft (algorithm): Difference between revisions

Content deleted Content added
No edit summary
Line 12:
 
==== Leader election ====
When the existing leader fails or when youthe startalgorithm your algorithminitializes, 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 for which a 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.
Line 49:
 
==== Timing and availability ====
Timing is critical in Raft to elect and maintain a steady leader over time, in order to have a perfect availability of yourthe cluster. Stability is ensured by respecting the ''timing requirement'' of the algorithm :<blockquote>''broadcastTime << electionTimeout << MTBF''</blockquote>
* ''broadcastTime'' is the average time it takes a server to send request to every server in the cluster and receive responses. It is relative to the infrastructure you are usingused.
* ''MTBF (Mean Time Between Failures)'' is the average time between failures for a server. It is also relative to yourthe infrastructure.
* ''electionTimeout'' is the same as described in the Leader Election section. It is something youthe programmer must choose.
Typical number for these values can be 0.5ms to 20ms for ''broadcastTime'', which implies that youthe setprogrammer sets the ''electionTimeout'' somewhere between 10ms and 500ms. It can take several weeks or months between single server failures, which means the values are all right for a stable cluster to work.
 
== References ==