Beruflich Dokumente
Kultur Dokumente
Topics
r Issues
r Detecting Failures
r Bully algorithm
r Ring algorithm
Readings
r Van Steen and Tanenbaum: 5.4
r Coulouris: 11.3
Election Algorithms
r Remember using Lamport clocks for total order
r Can you think of another way to do this?
r It turns out that you can use a sequencer.
m All operations go to a sequencer
m The sequencer assigns numbers to each message before
the message goes to each replica
m What if the sequencer goes down?
Election Algorithms
r Many distributed algorithms require a
process to act as a coordinator.
r The coordinator can be any process that
organizes actions of other processes.
r A coordinator may fail
r How is a new coordinator chosen or
elected?
Election Algorithms
Assumptions
Each process has a unique number to distinguish
them.
One process per machine (which suggests that
an IP address can be the unique identifier)
Processes know each other’s process number
Processes do not know which ones are currently
up and which ones are down.
General Approach
Locate the process with the process with the
highest process number and designate it as the
coordinator.
Election algorithms differ in how they do this.
Issues in Dealing with
Coordinator Failure
m Detecting Failure
• Any node might detect failure first
• Multiple processes might detect failure at once.
m Election
• Must run without coordination
• Must deal with arbitrary process failures
• All nodes must agree on when election is over and who
the new coordinator is.
Detecting Failures
r Timeouts are used to detect failures
T = 2Ttrans + Tprocess
• Where Ttran is maximum transmission delay and Tprocess
represents the maximum delay for processing a
message.
r If a process fails to respond to a message
request within T seconds then an election
is initiated.
Bully Algorithm
When a process, P, notices that the
coordinator is no longer responding to
requests, it initiates an election.
P sends an ELECTION message to all processes
with higher numbers.
If no one responds, P wins the election and
becomes a coordinator.
If one of the higher-ups answers, it takes over.
P’s job is done.
Bully Algorithm
r When a process gets an ELECTION
message from one of its lower-numbered
colleagues:
m Receiver sends an OK message back to the
sender to indicate that he is alive and will take
over.
m Receiver holds an election, unless it is already
holding one.
m Eventually, all processes give up but one, and
that one is the new coordinator.
m The new coordinator announces its victory by
sending all processes a message telling them
that starting immediately it is the new
coordinator.
Bully Algorithm
If a process that was previously down
comes back:
It holds an election.
If it happens to be the highest process
currently running, it will win the election and
take over the coordinator’s job.
“Biggest guy” always wins and hence the
name “bully” algorithm.
The Bully Algorithm (Example)
Initiation:
1. Process 4 sends an
ELECTION message to
its successor (or next
alive process) with its ID
Ring Algorithm
Initiation:
2. Each process adds its own
ID and forwards the
ELECTION message
Ring Algorithm contd…
Leader Election:
3. Message comes back to initiator, here
the initiator is 4.
4. Initiator announces the winner by
sending another message around the ring
Ring Algorithm Analysis