- 2074 Chaitra · 2+6 marks
Need of consensus; Bully algorithm
Short answer
Consensus is required for agreeing on commit/abort, leader election, and replica consistency, with properties of termination, agreement, and validity. The Bully algorithm elects the highest-id process as coordinator: a process noticing failure sends ELECTION to higher ids; if no reply, it declares itself coordinator and sends COORDINATOR to all. For example, with ids 0–7, if 7 fails, 4 initiates and 6 eventually wins.
Why is consensus needed in DS? Explain Bully algorithm with suitable example.
Need for consensus
Consensus means that a group of processes, each proposing a value, agree on one common value, even if some fail. It is needed whenever processes must act together:
- Deciding to commit or abort a distributed transaction.
- Electing a leader/coordinator or deciding who holds a resource.
- Keeping replicated state or logs identical (state machine replication, e.g. Paxos, Raft).
- Agreeing on the order of messages (total order multicast), membership of a group, or time-critical decisions (e.g. whether to launch). Required properties: termination (every correct process decides), agreement (same value for all), validity/integrity (the value was proposed by some process).
Bully algorithm (leader election)
Each process has a unique id, knows all other ids, and the highest alive id wins.
- A process P detecting that the coordinator has failed sends ELECTION to all processes with higher ids.
- If none replies within timeout, P becomes coordinator and sends COORDINATOR to all.
- If a higher process replies OK, P stops its election. The higher one then holds its own election.
- The process with the highest id ends up with no answer, and announces itself.
- A recovered process starts an election; if highest, it "bullies" its way to coordinator.
Example: processes 0 to 7, coordinator 7 crashes. P4 detects it and sends ELECTION to 5, 6, 7. 5 and 6 reply OK. P5 sends to 6, 7; P6 sends to 7. P6 receives no answer from 7, so it sends COORDINATOR(6) to everyone. All agree that 6 is the new coordinator, thus reaching consensus on the leader.
Worst case O(N²) messages (lowest process starts); best case N−2.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Bully algorithm vs ring algorithm · Distributed System, chapter 6
- Need of multicast and consensus · Distributed System, chapter 6
- Central coordinator election; consensus · Distributed System, chapter 6
- Election algorithm need and example · Distributed System, chapter 6 · asked 2×
- Consensus; highly available service · Distributed System, chapter 6
- Cristian's algorithm · Distributed System, chapter 5 · asked 3×
- Need for replacement algorithm in cache · Computer Organization and Architecture, chapter 6
- Need for non-uniform quantization; one algorithm · Communication Systems, chapter 4
- Why the Fourier transform is needed · Data Communication, chapter 3 · asked 2×
- Banker's algorithm, 5 processes, 4 resources · Operating System, chapter 7