/
CSE 486/586 Distributed Systems CSE 486/586 Distributed Systems

CSE 486/586 Distributed Systems - PowerPoint Presentation

pamella-moone
pamella-moone . @pamella-moone
Follow
371 views
Uploaded On 2016-05-13

CSE 486/586 Distributed Systems - PPT Presentation

Leader Election 2 Steve Ko Computer Sciences and Engineering University at Buffalo Algorithm 2 Modified Ring Election election message tracks all IDs of nodes that forwarded it not just the highest ID: 318308

coordinator election message algorithm election coordinator algorithm message coord ring process bully messages processes time receives timeout highest turnaround

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "CSE 486/586 Distributed Systems" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

CSE 486/586 Distributed SystemsLeader Election --- 2

Steve Ko

Computer Sciences and Engineering

University at BuffaloSlide2

Algorithm 2: Modified Ring Election election

message tracks

all

IDs of nodes that forwarded it, not just the highestEach node appends its ID to the listOnce message goes all the way around a circle, new coordinator message is sent outCoordinator chosen by highest ID in election messageEach node appends its own ID to coordinator messageWhen coordinator message returns to initiatorElection a success if coordinator among ID listOtherwise, start election anew

2Slide3

Example: Ring Election

Election:

2

Election:

2, 3,4,0,1

Election:

2,3,4

Election:

2,3

Coord(4):

2

Coord(4): 2,3

Coord(4) 2, 3,0,1

Election: 2

Election: 2,3

Election: 2,3,0

Election: 2, 3,0,1

Coord(3): 2

Coord(3): 2,3

Coord(3): 2,3,0

Coord(3): 2, 3,0,1

P1

P2

P3

P4

P0

P5

1. P2 initiates election

P1

P2

P3

P4

P0

P5

2. P2 receives

"

election

"

,

P4 dies

P1

P2

P3

P4

P0

P5

3. P2 selects 4 and announces the result

P1

P2

P3

P4

P0

P5

4. P2 receives

"

Coord

"

,

but P4 is not included

P1

P2

P3

P4

P0

P5

5. P2 re-initiates election

P1

P2

P3

P4

P0

P5

6. P3 is finally elected

3Slide4

Modified Ring ElectionHow many messages?

2N

Is this better than original ring protocol?

Messages are largerReconfiguration of ring upon failuresCan be done if all processes "know" about all other processes in the systemWhat if initiator fails?Successor notices a message that went all the way around (how?)Starts new electionWhat if two people initiate at onceDiscard initiators with lower IDs4Slide5

What about that Impossibility?Can we have a

totally correct

election algorithm in a fully asynchronous system (

no bounds)No! Election can solve consensusWhere might you run into problems with the modified ring algorithm?Detect leader failuresRing reorganization5Slide6

Algorithm 3: Bully Algorithm Assumptions:

Synchronous system

attr

=idEach process knows all the other processes in the system (and thus their id's)6Slide7

Algorithm 3: Bully Algorithm 3 message types

election

– starts an election

answer – acknowledges a messagecoordinator – declares a winnerStart an electionSend election messages only to processes with higher IDs than selfIf no one replies after timeout: declare self winnerIf someone replies, wait for coordinator messageRestart election after timeoutWhen receiving election message

Send

answer

Start an election yourselfIf not already running7Slide8

8

Example: Bully Election

OK

OK

P1

P2

P3

P4

P0

P5

1. P2 initiates election

2. P2 receives

replies

P1

P2

P3

P4

P0

P5

3. P3 & P4 initiate election

P1

P2

P3

P4

P0

P5

P1

P2

P3

P4

P0

P5

4. P3 receives reply

OK

Election

Election

Election

Election

Election

Election

P1

P2

P3

P4

P0

P5

5. P4 receives no reply

P1

P2

P3

P4

P0

P5

5. P4 announces itself

coordinator

answer=OKSlide9

The Bully Algorithm

The coordinator p

4

fails and p

1

detects this

p

3 fails

p1

p2p

3p4

p1

p2p

3p

4C

coordinatorStage 4

Celectionelection

Stage 2p

1p2

p3

p4C

election

answer

answer

election

Stage 1

timeout

Stage 3

Eventually.....

p

1

p

2

p

3

p

4

election

answer

election

9Slide10

Analysis of The Bully AlgorithmBest case scenario: The process with the second highest id notices the failure of the coordinator and elects itself.

N-2

coordinator

messages are sent.Turnaround time is one message transmission time.10Slide11

Analysis of The Bully AlgorithmWorst case scenario: When the process with the lowest id in the system detects the failure.

N-1 processes altogether begin elections, each sending messages to processes with higher ids.

The message overhead is O(N

2).11Slide12

Turnaround timeAll messages arrive within T units of

time (synchronous)

Turnaround time:

election message from lowest process (T)Timeout at 2nd highest process (X)coordinator message from 2nd highest process (T)How long should the timeout be?X = 2T + TprocessTotal turnaround time: 4T + 3TprocessHow long should election restart timeout be?X + T +

T

process

= 3T + 2Tprocess12Slide13

SummaryCoordination in distributed systems requires a leader processLeader process might fail

Need to (re-) elect leader process

Three Algorithms

Ring algorithmModified Ring algorithmBully Algorithm13Slide14

14Acknowledgements

These slides contain material developed and copyrighted by

Indranil

Gupta (UIUC).