Docsity

Systems Programming Lec6b - CCS2 Election Algorithms, Study notes of Computers and Information technologies

Partial preview of the text

Download Systems Programming Lec6b - CCS2 Election Algorithms and more Study notes Computers and Information technologies in PDF only on Docsity!

Coordination in Distributed Systems

Election Algorithms

1

Election Algorithms

A fundamental building block of distributed applications

Employed in:

Replicated services in which coordination is necessary

Reliable services in which continuation of service despite failures is important

Self-organizing services in which actors may need to know their status

relative to the other actors

For example:

A cluster management service may require that a single coordinator

is maintained per cluster,

  • despite variations in cluster membership and node failures.

If the system enters an illegal state,

e.g. no coordinator or multiple coordinators,

it must be returned to a legal state as quickly as possible.

2

Non functional requirements of election algorithms

A number of different election algorithms have been designed.

The non-functional requirements are generally the same for all election algorithms:

Scalability

Robustness (Fault Tolerance)

Efficiency

Low latency

4

Functional requirements of election algorithms

he various election algorithms differ in their design and thus in their internal function.

unctional requirements of election algorithms include:

The proportion of time that a master exists should be very high.

A replacement must be found quickly if the current master is removed.

Multi-master scenarios must be detected and resolved quickly.

Spurious elections caused by falsely detecting master failure should be avoided.

Normal-mode communication complexity

(the number of messages sent under master-present conditions)

must be low.

Election-mode communication complexity

(the number of messages,

and the number of rounds of messages required to elect a new master)

must be low.

Communications overhead

(the mean total communication bandwidth required by the election algorithm)

must be low.

5

The Ring algorithm

Similar to the bully algorithm, but the nodes are arranged in logical ring.

Nodes only communicate with their logical neighbours.

When the master is lost, its neighbours will notice (lack of periodic messages).

The nodes pass messages around the ring (in several rounds) to establish which is the

highest numbered node and to ensure consensus.

  1. Normal

operation

S(4)

M(7)

S(2)

S(1)

S(5)

  1. Master

fails

S(4)

M(7)

S(2)

S(1)

S(5)

X

S(4)

S(2)

S(1)

S(5)

  1. Node 1

notices the

failure.

Node 1 starts

the election

rounds.

S(4)

S(2)

S(1)

S(5)

  1. This continues

until a master is

chosen and

consensus is

reached.

  1. Node 5

takes over

as master.

S(4)

S(2)

S(1)

M(5)

7

Leader Pre-election

A backup master is selected while the system is operating normally.

If the master fails, the backup eventually detects the failure and takes over as master.

Selection of the backup needs an election algorithm, but the election is done during

normal operation so the system is leaderless for a shorter time.

The backup is just as likely to fail as the master.

  1. Master

fails

S

M

B

S

S

X

S

M

B

S

S

S

M

B

S

S

  1. Normal

operation

S

M

S

B

  1. New backup

Is selected

S

M

S

S

  1. Backup

takes over as

master

8

Determinism vs Non Determinism

Computer programs tend to be deterministic:

We can predict what will happen.

(Consider the election algorithms discussed earlier).

Deterministic behaviour is generally a major requirement of distributed applications.

Deterministic behaviour in distributed applications generally requires lots of messages:

More messages as scale increases.

More time required to send more messages (latency)

To ensure robustness, even more messages are needed.

Natural systems are non-deterministic;

They achieve their goals, but the exact behaviour is not predictable.

Non-deterministic behaviour can be achieved with much fewer, and simpler, messages.

Can non-deterministic solutions be gainfully deployed in distributed applications?

10

The Emergent Election Algorithm – Overview

The emergent election algorithm uses a novel design, consisting of:

a non-deterministic first stage

a deterministic second stage.

This design approach has enabled the algorithm to simultaneously meet all of the

functional and non-functional requirements discussed above,

without compromise.

In particular the communication complexity at all times, and the time complexity and

communication overheads of elections are independent of the size of the system.

A small number of slaves are sufficient to monitor the presence of the master and to

elect a replacement if it fails.

11

The Emergent Election Algorithm – Second Stage

A deterministic mechanism governs the slave-master interaction.

The fundamental requirement is that during an election, only a single slave can become master.

This requires that the slaves have some means of negotiating between themselves.

Slaves use timers to monitor the presence of the master by listening for its periodic messages;

On receipt the timer is restarted.

On timeout, a slave elevates to candidate status and broadcasts a candidate message.

The candidate message informs slaves that the master has failed, and the rank of the candidate.

Higher-addressed slaves then also elevate to candidate status and transmit candidate messages.

Nodes that receive higher-addressed candidate messages withdraw their candidacy.

Eventually only the highest-addressed candidate remains. It elevates to master status.

I

I

I

I

S

S

S

M

Slave pool

(decouples the

two stages)

Stage 1 interaction

(non-deterministic)

Stage 2 interaction

(deterministic)

13

Figure 4 State transitions in the Emergent Election Algorithm

Idle Slave Candidate Master

A

B^ E

F

H

G

D

C

Key:

A Slave pool too small (local view)

B Slave pool too large (local view)

C Slave timeout (no master messages received)

D Received lower-addressed candidate message

E Received higher-addressed candidate message

F Received master broadcast

G Candidate timeout (no higher-addressed candidate message received)

H Received higher-addressed master broadcast

Figure 4 State transitions in the Emergent Election Algorithm

Idle Slave Candidate Master

A

B^ E

F

H

G

D

C

Key:

A Slave pool too small (local view)

B Slave pool too large (local view)

C Slave timeout (no master messages received)

D Received lower-addressed candidate message

E Received higher-addressed candidate message

F Received master broadcast

G Candidate timeout (no higher-addressed candidate message received)

H Received higher-addressed master broadcast

Idle Slave Candidate Master

A

B^ E

F

H

G

D

C

IdleIdle SlaveSlave CandidateCandidate MasterMaster

A

B^ E

F

H

G

D

C

Key:

A Slave pool too small (local view)

B Slave pool too large (local view)

C Slave timeout (no master messages received)

D Received lower-addressed candidate message

E Received higher-addressed candidate message

F Received master broadcast

G Candidate timeout (no higher-addressed candidate message received)

H Received higher-addressed master broadcast

The Emergent Election Algorithm State-Transition diagram

14

The Emergent Election Algorithm Sensitivity to node failure

16

References (1)

Y. Métivier, N. Saheb and A. Zemmari, Randomized local elections,

Information Processing Letters , 82(6), June 2002, 313-320.

J. Beauquier, M. Gradinariu, C. Johnen and J Durand-Lose, Token-Based Self-Stabilizing Uniform Algorithms,

Journal of Parallel and Distributed Computing , 62, 899-921, Elsevier Science (USA), 2002

S. Singh and J. Kurose, Electing Good Leaders,

Journal of Parallel and Distributed Computing , 21, 184-201, Academic Press, 1994

S. Singh and J. Kurose, Electing Leaders based upon Performance: the Delay Model, ch2996-7/91/0000/0464, 464-471, IEEE,

H. Garcia-Molina, Elections in a Distributed Computing System, Transactions on Computers , IEEE, C31(1), 1982, 48-59.

H. Abu-Amara and J. Lokre, Election in Asynchronous Complete Networks with Intermittent Link Failures,

Transactions on Computers , IEEE, 43(7), 1994, 778-788.

P. Flocchini and B. Mans, Optimal Elections in Labeled Hypercubes,

Journal of Parallel and Distributed Computing , Academic Press, 33, 1996, 76-83.

T. Kalamboukis and S. Mantzaris, Towards optimal distributed election on chordal rings,

Information Processing Letters , 38(5), June 1991, 265-270.

G. Singh, Leader Election in the Presence of Link Failures,

Transactions on Parallel and Distributed Systems , 7(3), 231-235, IEEE, 1996

S. Ghosh and A. Gupta, An exercise in fault-containment: Self-stabilizing leader election,

Information Processing Letters , 59, 281-288, Elsevier Science, 1996

C. Fetzer and F. Cristian, A Highly Available Local Leader Election Service,

Transactions on Software Engineering, 25(5), 603-618, IEEE, 1999

17