skip to main content
Choosing a Leader
When a server receives a valid ballot from another member, it records that server as a potential leader candidate. A ballot is considered valid for twice the election period. For example, a received ballot will be counted in any election that occurs within 20 seconds of the timestamp on the ballot. This window helps accommodate minor clock differences between servers and issues related to Nyquist rate.
During each election, every server determines the leader by ranking candidates based on the number of votes they receive (the votes property of the ballot). If one server receives more votes than the others, it is declared the winner. However, if multiple servers have the same priority, they will receive the same number of votes, resulting in a tie. In such cases, the winner is chosen from the tied candidates by selecting the server with the lowest ID (sorted alphabetically).
It is important to note that winning the election does not automatically make a server the leader. Additional criteria must be met for the winning server to assume leadership:
1. The group must not already have a leader: If a new candidate server comes online and its ID would make it the natural leader, it will not assume leadership as long as an existing server is claiming to be the leader. The exception to this rule is if a new server has a higher priority; it will immediately take over leadership. This approach prevents unnecessary leader changes while still allowing administrators to force a server into leadership (by increasing its priority) or into standby (by decreasing its priority).
2. The quorum must be met: Server groups are configured with a quorum strategy, which represents the number of elector servers that must submit a ballot for the election to be valid. For example, if a server group of three servers uses a "majority" quorum strategy, and two servers fail (leaving only one), the remaining server cannot be elected leader because it does not meet the quorum requirement. In such cases, no server will be elected leader, and the system will remain in a standby/offline state. Refer to the "Quorum" section for details and special considerations.
3. The winner must be chosen consecutively: By default, a server must win two consecutive elections before becoming the leader. This prevents situations where a server briefly declares itself the leader due to initial conditions when coming online without receiving ballots from competitors. It also reduces leadership changes caused by temporary network glitches.
Once elected, the leader becomes active while all other servers go into standby mode. Although elections occur frequently (every 10 seconds, by default), the outcome should rarely change unless a candidate server goes offline.