Giter Site home page Giter Site logo

leader-election's Introduction

Build Status Test Coverage Quality Gate Licence

Leader Election

Bully Algorithm

Assumptions

  1. The system is synchronous.
  2. Processes may fail at any time, including during execution of the algorithm.
  3. There is a failure detector which detects failed processes.
  4. A process fails by stopping and returns from failure by restarting.
  5. Message delivery between processes is reliable.
  6. Each process knows its own process id and address, and that of every other process.

Algorithm

The algorithm uses the following message types:

  1. Election Message: Sent to announce election
  2. Answer (Alive) Message: Responds to the Election message
  3. Coordinator (Victory) Message: Sent by winner of the election to announce victory

When a process P recovers from failure, or the failure detector indicates that the current coordinator has failed, P performs the following actions:

  1. If P has the highest process id, it sends a Victory message to all other processes and becomes the new Coordinator. Otherwise, P broadcasts an Election message to all other processes with higher process IDs than itself.
  2. If P receives no Answer after sending an Election message, then it broadcasts a Victory message to all other processes and becomes the Coordinator.
  3. If P receives an Answer from a process with a higher ID, it sends no further messages for this election and waits for a Victory message. (If there is no Victory message after a period of time, it restarts the process at the beginning.)
  4. If P receives an Election message from another process with a lower ID it sends an Answer message back and starts the election process at the beginning, by sending an Election message to higher-numbered processes.
  5. If P receives a Coordinator message, it treats the sender as the coordinator.

Implementation Notes

  1. Let process ID be a Type 4 UUID. Note that UUIDs will need to be comparable.
  2. As an invariant, the process ID does not change during the lifetime of a process.
  3. The lifetime of a process will be denoted by an epoch stamped on all the members in a cluster.
  4. From leader election to leader death, the cluster's epoch does not change. A new round bumps the cluster's epoch.
  5. For improved reliability (a stretch goal), metadata of cluster members, leadership, epochs are/can be saved in persistent storage.
  6. Satisfying assumption #1: TCP is used as the transport.
  7. Satisfying assumption #2,6: addition/removal of cluster members will be broadcasted to all processes participating in leader election.
  8. Satisfying assumption #3: a heartbeat-based failure detector is provided.
  9. Satisfying assumption #4: processes obey fail-stop maxim.
  10. Satisfying assumption #5: Blocking I/O is used in conjunction with TCP as the transport.

leader-election's People

Contributors

gsharma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.