written 2.9 years ago by |
Bully election algorithm
The bully algorithm is a type of Election algorithm which is mainly used for choosing a coordinate. In a distributed system, we need some election algorithms such as bully and ring to get a coordinator that performs functions needed by other processes.
Election algorithms select a single process from the processes that act as coordinators. A new process is selected when the selected coordinator process crashes due to some reasons. In order to determine the position where the new copy of coordinator should be restarted, the election algorithms are used.
It assumes that each process has a unique priority number in the system, so the highest priority process will be chosen first as a new coordinator. When the current use coordinator process crashes, it elects a new process having the highest priority number. We note that priority number and pass it to each active process in the distributed system.
The Bully election algorithm is as follows:
Let's assume that P is a process that sends a message to the coordinator.
It will assume that the coordinator process is failed when it doesn't receive any response from the coordinator within the time interval T.
An election message will be sent to all the active processes by process P along with the highest priority number.
If it will not receive any response within the time interval T, the current process P elects itself as a coordinator.
After selecting itself as a coordinator, it again sends a message that process P is elected as their new coordinator to all the processes having lower priority.
If process P will receive any response from another process Q within time T:
a.It again waits for time T to receive another response, i.e., it has been elected as coordinator from process Q.
b.If it doesn't receive any response within time T, it is assumed to have failed, and the algorithm is restarted.