Reputation: 6364
Does the number of App instances and Zookeeper servers should be the same? I understand the requirement of 2F+1 to tolerate F failures but this is to tolerate failures of Zookeeper instances itself. But how about the number of App instances ? For example say I have 3 zookeeper servers and I have 2 instances of my APP running that are managed by zookeeper and at any given time only one instance of my App will be running in master mode and the other in standby mode. Now, I want to be able to tolerate one instance failure of my APP itself (not the zookeeper instance) such that the other instance of my APP which was running in a standby mode should be elected as a new leader. Would that work? or I must have 3 instances of my App and 3 Zookeeper servers?
What is the right configuration for number of App instances and Zookeeper servers ?
Upvotes: 1
Views: 159
Reputation: 9844
From the perspective of ZooKeeper, there is no requirement on running any particular number of application instances. The application instances are ZooKeeper clients. They are not members of the ZooKeeper ensemble (the server side), so they are not subject to the 2F+1 fault tolerance requirement.
The number of application instances may impact overall availability of your application though, depending on its design. (As you said in your example, you can run 2 instances and it would tolerate 1 failure.)
Note that your application's leader election is different from the ZooKeeper ensemble's internal leader election. Within the ZooKeeper ensemble, a quorum of servers (2F+1) is required to elect a leader, and then that ZooKeeper ensemble leader processes transaction proposals from clients. At the application layer, your code acts as a ZooKeeper client and performs its own leader election using something like the Leader Election recipe or the Apache Curator Leader Election API. The ZooKeeper ensemble nodes are not voting on which one of your application nodes becomes leader. Instead, your application nodes are voting on which one of them becomes leader, and they vote by coordination with the ZooKeeper ensemble, which already has its own leader.
Upvotes: 1