Bully Algorithm (Leader Election) – Notes
The Bully Algorithm is used in distributed systems to elect a coordinator (leader). The process is
based on process IDs (higher ID = higher priority).
Basic Idea:
- A process detects coordinator failure and starts election
- Sends ELECTION message to higher ID processes
- If no response → becomes leader
- If response received → higher process continues election
Example Diagram:
Step 1: P2 → sends ELECTION → P3, P4, P5
Step 2: P3 and P4 send OK to P2
Step 3: P3 and P4 start election
Step 4: No response from P5 (dead)
Step 5: P4 becomes coordinator
Step 6: P4 sends COORDINATOR to all
Hierarchy View:
P5 (Dead)
↑
P4 (Coordinator)
↑
P3
↑
P2 (Started Election)
↑
P1
Key Points:
- Highest ID process becomes leader
- Uses ELECTION, OK, COORDINATOR messages
- Simple but high message overhead