DISTRIBUTED SYSTEM
CHAPTER 10 : CASE STUDY
LAB WORK SOLUTION- DISTRIBUTED SYSTEM
DISTRIBUTED SYSTEM -BCA -ALL SLIDES
MCQ- DISTRIBUTED SYSTEM

In distributed systems, election algorithms are crucial for coordinating actions among distributed nodes and ensuring that a single node acts as the coordinator or leader. These algorithms are used to handle situations where a leader needs to be chosen among the nodes in the system. Two of the most well-known election algorithms are the Bully Algorithm and the Ring Algorithm.

Bully Algorithm

The Bully Algorithm works as follows:

  1. Initiation: When a node detects that the current leader has failed (usually through a timeout), it initiates an election.
  2. Election Message: The node sends an election message to all nodes with higher IDs.
  3. Response: If no node with a higher ID responds, the initiating node declares itself the leader and broadcasts a victory message.
  4. Higher-ID Node: If a higher-ID node responds, it takes over the election process by sending election messages to nodes with even higher IDs.
  5. Victory Message: The process continues until the highest-ID node declares itself the leader and broadcasts a victory message.

Ring Algorithm

The Ring Algorithm works as follows:

  1. Logical Ring: Nodes are organized in a logical ring structure where each node knows the address of its successor.
  2. Initiation: A node that detects a leader failure initiates the election by sending an election message containing its ID to its successor.
  3. Message Passing: The election message is passed around the ring.
  4. Highest ID: Each node compares its ID with the ID in the message. If the node's ID is higher, it replaces the ID in the message.
  5. Election Completion: When the message returns to the initiating node, it contains the highest ID in the system. This node is declared the leader, and a coordinator message is sent around the ring to inform all nodes of the new leader.