You are on page 1of 24

Leader Election

Bismita Srichandan
Leader Election
• What is Leader Election
• Why Leader election is needed
• Different design topologies
• Algorithms used
– Bully Algorithm
– Ring Algorithm
– Invitation Algorithm
• References
What is Leader Election?

• In distributed computing, leader election is the process of


designating a single process as the organizer, coordinator,
initiator or sequencer of some task distributed among several
computers (nodes).
Why Leader Election is required

• The existence of a centralized controller greatly simplifies process


synchronization

• However, if the central controller breaks down, the service


availability can be limited

• The problem can be alleviated if a new controller (leader) can be


chosen

How leader is chosen?


Ans: Different Algorithms are used for leader election.
Leader Election criteria(Chow et al,
1997)
• 1: Extrema finding - Leader election is based
on global priority.
• 2: Preference-based - Processes in the group
can vote for leader based on personal
preference (locality, reliability, estimation).
Leader Election Algorithms for Wireless Ad Hoc
Networks[10]
• Two algorithms, Secure Extrema Finding Algorithm (SEFA) and
Secure Preference-based Leader Election Algorithm (SPLEA).
• SEFA assumes that all elector-nodes share a single common
evaluation function that returns the same value.
• In SPLEA , the scenario becomes more complicated because
elector-nodes can have different preferences for a candidate-
node.
Leader Election Algorithms for Wireless Ad Hoc
Networks
• One relaxed assumption in synchronous distributed systems,
Asynchronous Extrema Finding Algorithm (AEFA) is used.
• In this we allow the topology to change during the election
process.
• In AEFA, nodes can start the process of election at different
times, but after topological changes stop long enough for the
algorithm to terminate, all nodes agree on a unique leader.
Election vs. Synchronization

Election Synchronization
• In election, all participants • In synchronization, the
must know who owns the nontoken holders only
token(i.e. who is the need to know that they do
leader). not hold the token.

• Election algorithms are • Synchronization algorithms


performed only if failure are designed to work well in
occurs. absence of failures.
Leader Election vs. Mutual Exclusion

Leader Election Mutual Exclusion


• Process may yield to others • Process competes until it
and execute normally as succeeds.
long as leader is selected. • Must ensure that no
• Concerned with fast and process is starved.
successful termination of • Does not care which
election process. process is running in critical
• Result of leader election section.
must be known to other
processes.
Design Topologies
• Complete Topology
• Logical Ring Topology
• Tree Topology

Complete Topology:
• Each process in the group can reach any other process in the same group
in one message hop.
• Assumptions taken
– All process ids are unique and known to every process
– Second assumption is communication network is reliable and only the communicating
processes may fail.
– Process takes a known finite amount of time to handle a message, in other words, the
process is considered as crashed if it doesn’t respond within specified time-out period.
*Note – Bully algorithm is based on the assumptions of complete topology
Bully Algorithm(Author : Tanenbaum)
• This is an extrema-finding algorithm.
• In this algorithm, the highest-numbered process becomes coordinator. Thus
the biggest guy in town always wins, hence the name “Bully Algorithm.”

• When a process notices that the coordinator is not responding to requests, it


initiates an election.

• Bully algorithm makes note of time of by which the process should respond.

• Election is held as follows:


– P sends an ELECTION message to all processes with higher numbers.
– If no one responds, P wins the election and becomes coordinator.
– If one of the higher-ups answers, it takes over. P’s job over!
Bully Algorithm

1.Process 4 holds an election.


2.Process 5 and 6 respond, sending OK
message that , we are UP.
3.Now 5 and 6 each hold an election.
Bully Algorithm
Process 6 tells 5 to stop
Process 6 wins and tells everyone

Process 6 tells 5 to stop


Process 6 wins and tells
everyone.
13
Logical Ring Topology
• Easy to construct

• Unique property is that a message initiated by


any node will return to the node.
Ring Algorithm

• In Ring algorithm if any process notices that the current coordinator


has failed, it starts an election by sending message to the first
neighbor on the ring.

• The election message contains the node’s process identifier and is


forwarded on around the ring.

• Each process adds its own identifier to the message.


• When the election message reaches the originator, the election is
complete.
• Coordinator is chosen based on the highest numbered process.
Ring Algorithm

Initiation:
1. Process 4 sends an ELECTION message to
its successor (or next alive process) with its
ID
2. Each process adds its own ID and
forwards the ELECTION message
Ring Algorithm contd…

Leader Election:
1. Message comes back to initiator, here the initiator is 4.
2. Initiator announces the winner by sending another message
around the ring
Tree Topology
• To construct a logical ring structure is easy if the underlying
network supports broadcast facilities.
• A tree is used as representative topological structure.
• Each node is considered an autonomous entity that
exchanges messages with adjacent nodes
• A minimum-weight spanning tree(MST) is used for leader
election in tree topology
• Gallager, Humbelt, and Spira’s algorithm is based on searching
and combining.
• It works by merging fragments, starting from each node and
attaching level by level till it ends up with the MST
• A leader can be designated as the last node that merges and
yields to the final MST.
Invitation Algorithm
• Invitation algorithm is a strong algorithm and it is basically designed for
asynchronous systems.

• It eliminates possible drawbacks of Bully algorithm.

Few drawbacks of Bully Algorithm

– Bully algorithm strongly uses the facts that timeouts can accurately
detect failed processors.
– An arbitrary timing glitch (lost messages, overfull buffers, temporary
overloads etc) , the bully algorithm can elect two leaders.
– Another possibility can be the node that fails to respond might not
have failed.
Invitation Algorithm contd…
• Each node in a group periodically checks whether the leader
is alive or not, by sending a message to the leader and waits
for reply.
• If the node does not reply within a timeout period, the node
invokes a Recovery procedure.
• The recovery procedure puts node i into a singleton group
with node i as the leader.
• periodically, each leader i calls a check procedure, which
sends messages to every other node asking whether that
node is a leader.
• If many nodes responds that it is a leader, node i pauses for
some time and then calls for a merge procedure.
Invitation Algorithm contd…
Merge procedure sends message to all the
leaders, inviting them to join a new group
with the inviting node as leader.

• Example :Group communication system in


Amoeba uses Invitation Algorithm to
reconfigure a group after a node crashes[8].
References
• [1] Distributed Operating Systems & Algorithms, Randy Chow and Theodore Johnson, Addison Wesley,
1997.

• [2] http://www.cs.wustl.edu/~kjg/CS333_SP97/leader.html

• [3] http://www.risc.uni-linz.ac.at/software/daj/Invitation/

• [4] http://ieeexplore.ieee.org

• [5] H. Garcia-Molina. Elections in a distributed computing system. IEEE Transactions on Computers, C-


31(1):47-59, January 1982.

• [6] http://www.cs.indiana.edu/pub/techreports/TR521.pdf

• [7] Distributed Systems principles and paradigms by Andrew S. Tanenbaum, Maarten van Steen, 2002.

• [8] M.F. Kaashoek and A.S. Tanenbaum, “Group Communication in the Amoeba Distributed Operating
System,” Proc. IEEE 11th Int'l Conf. Distributed Computing Systems (ICDCS), pp. 222-230, 1991.
References

Ring Algorithm
• [9] http://rocw.raifoundation.org/computing/BCA/distributedcomputing/lecture-notes/lecture-18.pdf

• [10]Vasudevan, S.; DeCleene, B.; Immerman, N.; Kurose, J.; Towsley, D.; “Leader election algorithms for
wireless ad hoc networks”, DARPA Information Survivability Conference and Exposition, 2003.
Proceedings


[11] Optimal Leader Election Scheme for Peer-to-Peer Applications
Networking, 2007. ICN '07. Sixth International Conference on Volume , Issue , 22-28 April 2007
http://ieeexplore.ieee.org/xpl/RecentCon.jsp?punumber=4196186
Thank You!

Questions

You might also like