# Distributed Systems – Bully Algorithm

September 10, 2009 2 Comments

Let’s assume that we have 7 nodes:

At this current moment in time, node ‘7’ is the coordinator, because it is the highest numbered node. But then node ‘7’ leaves, so who is now the coordinator? Lets say node ‘4’ decides it wants to be the coordinator, then we have:

Here, node ‘4’ has sent a ELECTION to nodes ‘5’, ‘6’ and ‘7’, this is because none of the nodes know that node ‘7’ has left yet. In this case, node ‘7’ cannot reply, yet, nodes ‘5’, and ‘6’ are still here, so they reply to ‘4’ that they are still here:

Now we have nodes ‘5’ and ‘6’ sending out elections. In this case, node ‘5’ sends an election to node ‘6’ and ‘7’. Whereas node ‘6’ just sends an election to node ‘7’:

Now, since node ‘6’ is still here, then node ‘6’ tells node ‘5’ that it is still here:

Finally, since node ‘7’ has not replied to node ‘6’, this implies that node ‘7’ no longer exists, meaning that node ‘6’ is the new coordinator. So node ‘6’ tells all the other nodes:

It was quite simple and interesting. I am working on this task to give an optimized way of this algorithm, but I think it is a best example for the total beginners.

Thanks! Came after after the wiki article failed to convince me.