Assign 5
Assign 5
TITLE:
Write a Program to Implement Bully Election Algorithm.
AIM:
To study and implement Bully Election Algorithm
OBJECTIVES:
1. To understand the working of election algorithms
2. To simulate bully algorithm
THEORY:
Elections:
In distributed systems, an election is the process of selecting a leader node among a group
of nodes. This leader node is responsible for coordinating the activities of the other nodes
and making decisions on behalf of the group. Elections are typically used to establish a
point of control and coordination in the system, and to ensure that there is always a
designated leader available to handle tasks such as coordinating communication,
managing resources, and making decisions.
There are several different algorithms that can be used to conduct elections in distributed
systems, each with its own strengths and weaknesses. Some of the most common
algorithms include the bully algorithm, the ring-based algorithm, the hierarchical
algorithm and the consensus-based algorithm (e.g. Paxos, Raft). The choice of algorithm
will depend on the specific requirements of the system, such as the number of nodes, the
network infrastructure, and the level of fault tolerance required.
Bully Algorithm:
The bully algorithm is a method used in distributed systems to elect a leader or
"coordinator" among a group of nodes. The algorithm works by having each node
broadcast a message to all other nodes claiming to be the leader. Nodes with a higher
priority will override the claims of nodes with a lower priority. In the event that the
current leader becomes unavailable, the nodes will continue to send out these messages
until a new leader is elected. This algorithm is named "bully" because the nodes with a
higher priority "bully" the nodes with a lower priority into submission. The bully
algorithm is simple but can have high network overhead and may not be suitable for
large-scale distributed systems.
Types of messages -
There are basically 3 types of messages:
1. An election message to initiate the election
2. A reply/response message given in response to the election message
3. A coordinator message sent to inform other processes, the id of the coordinator
process.
INPUT:
Process IDS
OUTPUT:
Selected Coordinator Process
PLATFORM:
Windows
PROGRAMMING LANGUAGE:
Python
CONCLUSION:
Thus, bully algorithm is successfully implemented.
FAQs
In the average case, the algorithm has a time complexity of O(n) where n is the number of
processes, as each process must send and receive messages from other processes before
determining who the coordinator is.
In the worst-case scenario, where there are many failures and a lot of processes are
constantly competing for the role of coordinator, the algorithm has a time complexity of
O(n^2) as each process must send and receive messages from other processes multiple
times before determining who the coordinator is.
It's important to note that the time complexity is based on theoretical analysis and the
actual time complexity can vary depending on the actual implementation and
the environment.