Election - Algorithms DCL - 5
Election - Algorithms DCL - 5
02/26/25 1
Election Algorithms
• There is a collection of processes/nodes that are identified by a
unique number
• A connection is established amongst the processes/nodes,hence
these can communicate with each other.Sending and Receiving
happens between these processes.
• A coordinator(leader) process needes to be elected through the
election algorithms
• And The coordinator election is done through election algorithms
02/26/25 2
Why elect a coordinator process ?
02/26/25 3
Types of messages
6.The non-faulty process with the best (highest) election attribute value (e.g., highest id or
address, or fastest cpu, etc.) is elected.
7. Requirement: A run (execution) of the election algorithm must always guarantee at the end:
a) safety and b) liveliness [ non-faulty process]
02/26/25 5
Ring algorithm
02/26/25 6
Ring Algorithm : Progress
Ring of N processes
33
17
24
15
28 24
(attr:=id)
1.The worst-case scenario occurs when the counter-clockwise neighbor has the highest attr/id
2. A total of N-1 messages is required to reach the new coordinator-to-be.
3.Another N messages are required until the new coordinator-to-be ensures it is the new coordinator.
4.Another N messages are required to circulate the elected messages.
worst case : 3N-1
best : 2N
02/26/25 8
Modified Ring Algorithm
1.A node initiates election by sending an “election” message to only nodes that have a higher id
than itself.
If no answer, announce itself to lower nodes as coordinator.
if any answer, then there is some higher node active; wait for coordinator message. If none received after time
out, start a new election.
2.A node that receives an “election” message replies with answer, & starts an election – unless
it has already.
3. When a process finds the coordinator has failed, if it knows its id is the highest, it elects itself
as coordinator, then sends a coordinator message to all processes with lower identifiers.
Bully Algorithm : Progress
Figure 6-20. The bully election algorithm. (d) Process 6 tells 5 to stop. (e) Process 6
02/26/25 wins and tells everyone. 13
Bully Algorithm : Time Complexity
• In the worst case,the bully algorithm requires O(n2) messages. When
the process having the priority number just below the failed
coordinator detects failure of coordinator, it immediately elects itself
as the coordinator and sends n-2 coordinator messages.
02/26/25 14