Service leader election system. Random, persistent, fair and anty-entropy :)

81 views
Skip to first unread message

Roman Rusakov

unread,
Mar 2, 2016, 7:12:58 PM3/2/16
to Consul
Hello people!

I have some strange use case for consul. I wonder if it can be elegantly use to achieve what we need?
Lets say we have set of services that are placed on set of nodes.
  1. Each service should be able to elect a leader on start.
  2. Leader should be persistent till he die - than new election.
  3. Leaders should be randomly placed on nodes.
  4. Whole system should tend to be fair balanced. (something like anty-entropy)

So at the any moment of time we should have a leader for each service, and number of leaders on particular node should be near or equal to number of leaders on other hosts.
Thanks a lot for any comments!

P.S. I am trying to figure out a way to get fair active/passive load balance logic.


Armon Dadgar

unread,
Mar 6, 2016, 9:45:56 PM3/6/16
to consu...@googlegroups.com, Roman Rusakov
Hey Roman,

Take a look at the “consul lock” command here: https://www.consul.io/docs/commands/lock.html
It implements a client-side leader election using Consul K/V which tends to be fair,
and holds the lock until a failure detector determines the lock holder is tend.

It is based on this guide here: https://www.consul.io/docs/guides/leader-election.html, and you
can implement that logic in your application if you’d like to avoid using a parent process
for the leader election.

Hope that helps!

Best Regards,
Armon Dadgar
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/consul/issues
IRC: #consul on Freenode
---
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/consul-tool/b6c74032-5c6e-4cc9-b9c8-5c6a47cac4a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages