Michael, Leader election is not enough. You must have some mechanism to fence off the partitioned leader.
If you are building a replicated state machine Apache Zookeeper + Apache Bookkeeper can be a good choice See this just an example: https://github.com/ivankelly/bookkeeper-tutorial This is the "bible" for ZooKeepers and it describes how to build such systems and the importance of "fencing" https://www.amazon.com/ZooKeeper-Distributed-Coordination-Flavio-Junqueira-ebook/dp/B00GRCODKS If you are interested in BookKeeper ping on user@ Apache BookKeeper mailing list Enrico Il gio 6 dic 2018, 08:18 Michael Borokhovich <michael...@gmail.com> ha scritto: > Thanks, I will check it out. > However, do you know if it gives any better guarantees? > Can it happen that we end up with 2 leaders or 0 leader for some period of > time (for example, during network delays/partitions)? > > > > On Wed, Dec 5, 2018 at 10:54 PM 毛蛤丝 <maoling199210...@sina.com> wrote: > > > suggest you use the ready-made implements of curator: > > http://curator.apache.org/curator-recipes/leader-election.html > > ----- 原始邮件 ----- > > 发件人:Michael Borokhovich <michael...@gmail.com> > > 收件人:"dev@zookeeper.apache.org" <dev@zookeeper.apache.org> > > 主题:Leader election > > 日期:2018年12月06日 07点29分 > > > > Hello, > > We have a service that runs on 3 hosts for high availability. However, at > > any given time, exactly one instance must be active. So, we are thinking > to > > use Leader election using Zookeeper. > > To this goal, on each service host we also start a ZK server, so we have > a > > 3-nodes ZK cluster and each service instance is a client to its dedicated > > ZK server. > > Then, we implement a leader election on top of Zookeeper using a basic > > recipe: > > https://zookeeper.apache.org/doc/r3.1.2/recipes.html#sc_leaderElection. > > I have the following questions doubts regarding the approach: > > 1. It seems like we can run into inconsistency issues when network > > partition occurs. Zookeeper documentation says that the inconsistency > > period may last “tens of seconds”. Am I understanding correctly that > during > > this time we may have 0 or 2 leaders? > > 2. Is it possible to reduce this inconsistency time (let's say to 3 > > seconds) by tweaking tickTime and syncLimit parameters? > > 3. Is there a way to guarantee exactly one leader all the time? Should we > > implement a more complex leader election algorithm than the one suggested > > in the recipe (using ephemeral_sequential nodes)? > > Thanks, > > Michael. > > >