Bully Algorithm

It follows all the assumptions discussed above in the Election Algorithm.

Let’s say there are 6 Processes P0, P1, P2, P3, P4, P5 written in ascending order of their Process ID (i.e.,0, 1,2,3,4,5).

The Bully Algorithm operates on the principle of higher priority.

Messages in Bully Algorithm

There can be three types of messages that processes exchange with each other in the bully algorithm:

1. Election message: Sent to announce election.

2. OK (Alive) message: Responds to the Election message.

3. Coordinator (Victory) message: Sent by winner of the election to announce the new coordinator.

Steps Involved in Bully Algorithm

Step 1: Suppose Process P2 sends a message to coordinator P5 and P5 doesn’t respond in a desired time T (possible reason could be crash, down, etc.)

Step 2: Then process P2 , sends an election message to all processes with Process ID greater than P2 (i.e. P3, P4 & P5) and awaits a response from the processes.

Initiation of Election by P2

Step 3: If no one responds, P2 wins the election and become the coordinator.

Step 4: If any of the processes with Process ID higher than 2 responds with OK, P2’s job is done and this Process will take over.

Step 5: It then restarts and initiates an election message.

Re-initialization of Election

Step 6: Process P4 responds to P3 with an OK message to confirm its alive state and Process P4 figures out that process 5 has crashed, and the new process with the highest ID is process 4.

Step 7: The process that receives an election message sends a coordinator message if it is the Process with the highest ID (in this case it is P4).

P4 wins the election and becomes the new coordinator

Step 8: If a Process which was previously down (i.e. P5) comes back, it holds an election and if it has the highest Process Id then it will become the new coordinator and sends message to all other processes.

P5 is the highest priority process , hence became the coordinator.

Bully Algorithm in Distributed System

Operating Systems play a critical role in managing and coordinating the activities of a computer system. In distributed systems, where multiple computers work together to achieve a common goal, the issue of node/process failure becomes a significant concern. To ensure the reliability and fault tolerance of a distributed system, leader election algorithms come to the rescue. In this article, we will discuss the leader election algorithm (Bully algorithm) and understand how it guarantees the election of a new coordinator when the current coordinator fails.

Similar Reads

Understanding Leader Election Algorithm

The election algorithm is based on the following assumptions:...

Bully Algorithm

It follows all the assumptions discussed above in the Election Algorithm....

Practical Applications of the Bully Algorithm

The Bully Algorithm finds applications in various distributed systems, including:...

Pros of the Bully algorithm

Simple: The bully algorithm is easy to understand and implement. Effective in small networks: The bully algorithm has low overhead in smaller distributed systems. Fault-tolerant: The bully algorithm can elect a new leader if the current leader fails....

Cons of the Bully algorithm

Inefficient in large networks: The bully algorithm can introduce message overhead and delays in larger distributed systems. Risk of starvation: Lower-ranked nodes may never become leaders in some cases. Initialization challenges: The bully algorithm requires accurate Process rankings, which can be difficult to achieve in practice. Lack of preemption: The bully algorithm is non-preemptive, meaning that the current leader cannot be preempted by a higher-ranked Process....

Conclusion

In distributed systems, the Bully Algorithm is a simple and fault-tolerant leader election technique. It performs well in small- to medium-sized networks, maintaining order in the event of a leader failure. However, it lacks preemption capabilities and its efficiency can drop in larger networks....

Contact Us