Bully algorithm
Appearance
In distributed computing, the bully algorithm is a method for dynamically electing a coordinator or leader by process ID number. The process with the highest process ID number is selected as the coordinator.
Assumptions
The algorithm assumes that:[1]
- the system is synchronous and timeouts identify process failure.
- processes may crash during execution of the algorithm.
- message delivery between processes is reliable.
- each process knows the process id and address of every other process.
Algorithm
The algorithm uses the following message types:
- Election Message: Sent to announce election
- Answer (Alive) Message: Responds to the election message
- Coordinator (Victory) Message: Sent by winner of the election to announce victory.
When a process P recovers from failure, or determines that the current coordinator is down because of message timeouts, it performs the following sequence of actions:
- If P has the highest process id, it sends a Victory message to all other processes and becomes the new Coordinator. Otherwise, P broadcasts an Election message to all other processes with higher process IDs than itself.
- If P receives no Answer after sending an Election message, then it broadcasts a Victory message to all other processes and becomes the Coordinator.
- If P receives an Answer from a process with a higher ID, P waits a certain amount of time for another process with a higher ID to broadcast a Victory message to all other processes. If it does not receive a Victory message in time, it re-broadcasts the Election message.
- If P receives an Election message from another process with a lower ID it sends an Answer message back and starts a new election (that is, P sends Election messages to the processes with higher ids than itself).
- If P receives a Coordinator message, it treats the sender as the coordinator.
See also
References
- ^ Jean Dollimore, Tim Kindberg, George F. Coulouris, "Distributed systems : concepts and design (Third Edition)," in Distributed systems : concepts and design (Third Edition). Addison–Wesley, 2003.
- Witchel, Emmett (2005). "Distributed Coordination". Retrieved May 4, 2005.
- Hector Garcia-Molina, Elections in a Distributed Computing System, IEEE Transactions on Computers, Vol. C-31, No. 1, January (1982) 48–59
- L. Lamport, R. Shostak, and M. Pease, "The Byzantine Generals Problem" ACM Transactions on Programming Languages and Systems, Vol. 4, No. 3, July 1982.