Institute of Computer Science
  1. Courses
  2. 2020/21 spring
  3. Distributed Systems (LTAT.06.007)
ET
Log in

Distributed Systems 2020/21 spring

  • General
  • Lectures
  • Practical work
  • Study materials
  • Practical work submission
  • Message board

Seminar 7: Election Algorithms

Goal:

  • To understand the concept behind Election Algorithms.
  • Learn how to apply election algorithm by bullying to a system of processes

Description: In Election algorithms, We require some Processes to act as a Coordinator. The main issue here is to how to select this Coordinator dynamically.

Basic Assumptions:

  • All processes have unique id’s
  • All processes know id’s of all processes in the system (but not if they are up or down)
  • Election means identifying the most suitable process based on different factors, e.g., highest id

Definitions

  • In Election Algorithms, one process needs to act as a coordinator.
  • The technique or algorithm here is to pick up a Unique Coordinator.
  • The need to choose a Unique Coordinator arises in case of a failed process or when we need to pick a master in Berkeley Clock Synchronization Algorithm.
  • Types of Election Algorithm:
    • Bully Algorithm
    • Ring Algorithm
  • Bully Algorithm:
    • Each process has a Unique Numerical ID.
    • Processes know the ID's and address of every other process.
    • Communication is assumed to be reliable.
    • The key idea as mentioned earlier is to select process with highest ID.
    • Process initiates election if it just recovered from failure or if coordinator has just failed.
    • Several Processes can initiate an election simultaneously.
    • The messages required to be sent with n Processes is of the order of O(n2)
    • Algorithm: Consider N processes (P0 …..PN -1) and let id(PK) = k. When a process PK notices that the coordinator is no longer responding to requests, it initiates an election:
      • PK sends an ELECTION message to all processes with higher identifiers: PK+1, PK+2 ..... PN-1
      • If no one responds, PK wins the election and becomes coordinator.
      • If one of the higher-ups answers, it takes over and PK's job is done.
    • Algorithm Explained: Suppose Process P sends a message to the coordinator:
      • If Coordinator does not respond to the request within a time interval T, then it is assumed that the coordinator has failed.
      • Now Process P sends election message to every process with high priority number.
      • It waits for response, if no process responds in time interval T, then process P elects itself as Coordinator.
      • Then it sends a message to all lower priority numbers that it is elected as their new coordinator.
      • However, if an answer is received within time T from any other process Q:
        • Process P again waits for time interval T to receive another message from Q that it has been elected as Coordinator.
        • If Q doesn't respond within time interval T, Then it is assumed to have failed and the algorithm is restarted. For Example:

In the above example, Process 7 which was the Coordinator fails. Process P4 starts an election and a total of 15 messages are required to elect a new coordinator. The number of messages required depends on which Process initiates the election:

  • If Process 0 starts an election, maximum number of messages will be required to elect a new coordinator (Worst Case).
  • If Process 6 initiates an election, minimum number of messages will be required to elect a new coordinator (Best Case).

EXERCISE: The figure shows 6 processes where process 6 is the coordinator, as it has the highest ID. Assume Process 6 fails, resolve using bullying algorithm and answer the following:

  • What is the number of messages required to elect a new coordinator, if:
    • Process 1 initiates an election (Worst Case)
    • Process 2 initiates an election
    • Process 3 initiates an election
    • Process 4 initiates an election
    • Process 5 initiates an election (Best Case)
  • Generalise a formula that estimates the number of messages required in a network of N processes to select a new coordinator in worst case scenario.
    • Hint:
      • The number of messages required in a network of N Processes is of the order of O(N2)
      • Derive a formula for the number of messages sent in worst case. In such as case, Process with the lowest ID initiates an election and sends N-1 messages and receives N-2 replies. After that, every i-th process (for i = 1,2,3 ...... N-1) will send N-i messages and receive N-i-1 replies. Finally, the (N-1) process wins and sends N-2 Coordinator messages
      • So f(N) = N - 1 + N - 2 + ({$\sum\limits_{i=2}^{N-1}$} (N - i) + (N - i - 1)) + N - 2
      • Now Solve (Apply Arithmetic Sum Rule)

Deliverables of practical session: A PDF file containing the answers to above exercise.

  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment