{"id":17548672,"url":"https://github.com/djo/leader_election","last_synced_at":"2025-03-29T06:29:35.961Z","repository":{"id":16145365,"uuid":"18890931","full_name":"djo/leader_election","owner":"djo","description":"Leader Election Implementation","archived":false,"fork":false,"pushed_at":"2014-10-06T13:10:19.000Z","size":264,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T19:07:04.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-17T19:33:02.000Z","updated_at":"2024-03-23T12:19:11.000Z","dependencies_parsed_at":"2022-09-03T00:00:43.275Z","dependency_job_id":null,"html_url":"https://github.com/djo/leader_election","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Fleader_election","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Fleader_election/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Fleader_election/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Fleader_election/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djo","download_url":"https://codeload.github.com/djo/leader_election/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246149773,"owners_count":20731405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-21T02:24:43.880Z","updated_at":"2025-03-29T06:29:35.930Z","avatar_url":"https://github.com/djo.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Leader Election Algorithm\n[![Build Status](https://travis-ci.org/Djo/leader_election.svg)](https://travis-ci.org/Djo/leader_election)\n\n[The bully algorithm](http://en.wikipedia.org/wiki/Bully_algorithm) is one of methods in [distributed computing](http://en.wikipedia.org/wiki/Distributed_computing) for implementation of the [leader election](http://en.wikipedia.org/wiki/Leader_election) process for dynamically electing a coordinator by process ID number. The process with the highest number is selected as the coordinator.\n\n### Build\n\nTo run the algorithm you need a working installation of Erlang R15BXX (or later).\n\n    $ make get-deps\n    $ make compile-all\n\n### Usage\n\nConfigure `timeout` and `nodes` in the `bully.config`.\n\n    $ ./start.sh 1@127.0.0.1\n    $ ./start.sh 2@127.0.0.1\n    $ ./start.sh 3@127.0.0.1\n    $ ./start.sh 4@127.0.0.1\n\nThen you can kill a node and see logs.\n\n### Description\n\nImplementation consists of monitoring of the current leader and election a new one\nwhen the current is unavailable. The election of a new leader should be done as soon as possible.\nYou have a distributed network from `N` nodes where each node described by an unique identity number.\n\n#### Monitoring of the current leader\n\nEach node sends `ping` every `T` seconds to the current leader and waits `4*T` seconds for `pong` reply.\nOn the waiting timeout the leader election process should be started.\n\n#### Leader election process\n\n1. A node started the election starts sending `announce election` to all nodes\n   with a higher identity number and waits for `ok`.\n    * If no one `ok` after `T` seconds the node starts leading and sends `new leader` to all nodes.\n    * If received `ok` the node starts waiting for `new leader` next `T` seconds.\n      On `new leader` waiting timeout the node starts announcing election again.\n2. When receiving `announce election` a node replies with `ok` and starts the election process itself.\n    * If the node received `announce election` is with the highest identity number it starts leading\n      with sending `new leader` to all nodes.\n3. When receiving `new leader` a node saves a new leader and starts monitoring it.\n\n#### Example\n\n![Example](https://raw.github.com/Djo/leader_election/master/example.png)\n\nInspired by an article about a test task from [aboutecho.com](http://www.echorussia.ru/jobs/serverside-june-2013.html).\n\nCopyright (C) 2014 [Andrew Djoga](http://andrewdjoga.com), released under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjo%2Fleader_election","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjo%2Fleader_election","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjo%2Fleader_election/lists"}