1

I was wondering whether a non-deterministic leader election algorithm exists (in a one directional ring) that ensures termination. I cannot think of one nor can I find one that is non-deterministic. Some that I've found are:

  • Select the node with the highest process ID to be the leader (deterministic) and terminates.

  • Randomly decide whether a node wants to be a leader, if in the ring there is another node that wants to be a leade, restart the whole process. This one does not terminate, but has a probability of termination.

Can someone either give me some hints on how to create a distributed non-deteministic leade election algorithm? And maybe explain it in layman terms.

Thanks for everything!

Snowflake
  • 2,869
  • 3
  • 22
  • 44
  • 2
    I'm not sure whether I fully understand the question, but can you assign a random number to the nodes, highest / lowest is leader? – vlad Mar 13 '13 at 20:51
  • 1
    Treat each candidate as a card in a deck of playing cards, then shuffle the deck and take the person on top as the leader? Shuffling a deck of cards can be made both [distributed and cryptographically-secure](http://en.wikipedia.org/wiki/Mental_poker#Shuffling_cards_using_commutative_encryption). – BlueRaja - Danny Pflughoeft Mar 13 '13 at 21:46
  • Dear Vlad, that doesn't make sense, since if I did that, then it will be kind of doing the same as "assigning process ID's" to all the processes. Dear Blue Raja, I cannot do this, because there is no "general" authority to "shuffle" the cards. All nodes start at the same time and are aware of each other (since they can send messages to them), however they should decide on their own how to select a leader (they all share the same code btw). – Snowflake Mar 14 '13 at 00:58

2 Answers2

1

There exists no probabilistic (anonymous) leader election algorithm with both, a guaranteed termination and a guaranteed correctness (only one leader). If I remember right, you will find a proof in N. Lynch's book on Distributed Systems.

However, there exists algorithms with a probability limit of zero for non-termination for a sufficient long runtime of the algorithm. In addition, the expected runtime is rather short (AFIR, in the order of ln(k) for k initiators).

The main idea for such an algorithm follows your second approach. However, do not simple restart the process in case of several leaders, but only allow the winners of the last round to become candidates in the next round.

EDIT 1-3:

If you asking for a non-anonymous leader election, there are several probabilistic algorithms that guarantees termination. E.g., take a normal ring algorithm and delay messages with with a certain probability, as smaller the ID as greater the chance for delay. In this way, messages with low chance of winning are erased earlier, resulting in less overall messages.

If you want to have a different outcome for non-anonymous members, you can e.g. use a two phase algorithm:

  1. Perform a classical leader election => a nodes A with the highest ID wins
  2. Let A roll a dice to determine the actual leader.

The element of fortuity could also be distributed:

  1. Any nodes knows the set of identities (S) (if not, use a flooding algorithm to tell)
  2. All nodes select by chance an ID of ouf S and send it to any other node
  3. The ID that is named most often, wins. If there is more than one such ID, select one of them in a deterministic way, e.g., the median.

Termination and a non-deterministic outcome are granted for both alogrithm. However, the first has a lower average message complexity (n log n vs. ; the worst case complexity is the same) and is more fair (i.e., the probability that a ID wins is equaly distributed, what is not true for the second algorithm). I'm pretty sure, that at least the last disadvantage can eliminated by a more sophisticated algorithm, but the question here was for the general existence of such an algorithm.

Matthias
  • 8,018
  • 2
  • 27
  • 53
  • Dear Matthias, I am not asking for an anonymous leader election algorithm since we can use the process ID information part. Maybe I should clarify what I mean with a nondeterministic program. A non-deterministic program is a program that given the same input every time, can show different executions and thus give different results. Furthermore I think what you describe here is a probabilistic algorithm and I'm wondering how it can guarantee termination... Thanks for your reply though! – Snowflake Mar 14 '13 at 01:01
  • Dear Matthias, I indeed also thought about a two phase algorithm. However it kind of seems pointless choosing "the actual leader" again in my opinion though. Are there alternatives? – Snowflake Mar 21 '13 at 06:52
0

From what I understand from the question, you're not actually looking for an election algorithm, just a distributed algorithm to fairly and randomly choose one client as "leader," where no subset of clients can work together to cheat.

This is actually pretty easy. Treat each client as a card in a deck of cards, then use the mental poker algorithm (which is a distributed algorithm to fairly and randomly shuffle a deck of cards) to shuffle it. Then just take the first card as the leader.

BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283