K
K
Katya Smirnova2022-01-04 23:53:53
Distributed Computing
Katya Smirnova, 2022-01-04 23:53:53

How do leader election algorithms work in distributed systems?

Hello, for the sake of interest, I decided to study the topic of distributed, highly loaded systems, read a couple of smart books that talked about replication and algorithms for choosing a new leader (Leader Election) in case of failure of the current one. In particular, I learned about the Bully algorithm , Modified Bully and Ring algorithms.

A couple of questions immediately appeared:

- Absolutely in all these algorithms such a concept as priority is mentioned. Whichever node has a higher priority is appointed the new leader. Is this priority a random number? Or it usually depends on some node parameters, such as the amount of available memory, disk usage, and so on.
- If the priority is a random number, why then do you need to poll each node and create such a long chain of Election requests? You can simply do this - some node noticed that the current leader has fallen off, and it immediately sends to all other nodes directly, or to some bus, that it is now the leader. In fact, this will be exactly the same random node as in the case of priorities, only without a huge chain of requests.

Modified-Bully-Algorithm.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2022-01-05
@sireax

You can simply do this - some node noticed that the current leader has fallen off, and it immediately sends to all other nodes directly, or to some bus, that it is now the leader.

If the current leader falls off, why do you think that all the other nodes will know about it in turn?
They know at the same time. And at the same time they will send to all nodes that they are new leaders, and it will turn out to be a mess.
That is why a choice is made - either a random number is generated by each node, and the one with the largest number is selected among all. Or there are pre-set priorities for choosing leaders, based either on configs or on capacities, as the creator of the program seemed to need.
Again, settings can be added to the algorithm so that the administrator can specify which machines should not participate in the selection.

R
Roman Kitaev, 2022-01-05
@deliro

https://raft.github.io/

D
Dimonchik, 2022-01-05
@dimonchik2013

for the captains of warships there is such a thing like an adding machine: during a torpedo attack, turn so many degrees - a degree thing and chooses
so that the captains do not play smart against strict mathematics already calculated for them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question