Talk Zookeeper (one) analysis of the quorums mechanism of zookeeper--prevention of Split-brain problems

Source: Internet
Author: User

Use zookeeper students should see a parameter. It is zookeeper that more than half of the cluster must have nodes (Majority) available. Foreign talent is available throughout the cluster. In most cases, this statement is correct.

Talk about the reasons behind this article.


In fact zookeeper provides several ways to determine whether an entire cluster is available, majority is just one of them. Http://zookeeper.apache.org/doc/r3.3.5/zookeeperInternals.html

1. Majority quorums

2. Weight

3. Hierarchy of Groups


The so-called whole cluster is available. One implication is that the entire cluster can also elect a "Leader". The default setting for zookeeper is to support leader elections in a way that uses majority qunroms. The Quorums has 2 functions in zookeeper:

1. The minimum number of nodes in the cluster is used to elect leader to ensure the cluster is available

2. Notifies the client that the data has been saved by the minimum number of nodes in the cluster before it is safely saved.

Once these nodes have saved the data. The client will be notified that it has been safely saved. Able to continue other tasks. And the remaining nodes in the cluster will finally save the data.


The election of leader by Quoroms voting is mainly to solve the problem of "split-brain". Http://linux-ha.org/wiki/Split_Brain


The split-brain problem is that 1 clusters assume that a network failure has occurred. It is very likely that 1 clusters are divided into two parts. These two parts do not know whether the other side is alive. Do not know whether the network problem or the direct machine down, so the two parts are to elect 1 leader, and once the two parts have elected leader, and the network resumed, then there will be two brain, the whole cluster behavior is inconsistent.


So the cluster to prevent the emergence of split-brain problems, Quoroms is a way, that is, only more than half of the nodes in the cluster vote talent election leader. Zookeeper by default in this way.

To solve the problem of split-brain more broadly, there are generally 3 ways

1. Quorums

2. Use redundant communications. The way of redundant communication, a variety of communication methods are adopted in the cluster, which prevents the nodes in the cluster from communicating because of the failure of a communication mode.


3. Fencing, the way to share resources, such as the ability to see shared resources is represented in the cluster, the lock that can get shared resources is leader. Cannot see shared resources, it is not in the cluster


Understanding Quorums is not difficult to understand why the number of nodes in a cluster is generally configured to be odd. The number of nodes configured into odd clusters is more tolerant.

For example, a cluster of 3 nodes. Quorums = 2, which means that the cluster can tolerate 1 node failures. 1 leads can be elected at this time, and the cluster is also available

For example, a cluster of 4 nodes, its quorums = 3. Quorums to more than 3, the equivalent of cluster tolerance or 1. Assume that 2 nodes fail. Then the whole cluster is still invalid.

So the tolerance of the cluster of 4 nodes = The tolerance of the cluster of 3 nodes. However, the cluster of 4 nodes has more than 1 nodes, which is equivalent to wasting resources.


The more extreme example is a cluster of 100 nodes, which assumes that the network problem is divided into two parts. 50 nodes and 50 nodes, so that the entire cluster is not available, due to the way in accordance with the quorums must be 51 nodes to ensure the selection of 1 leader. It is possible to use the weight weighting method. The weights of some nodes are high, the weights of some nodes are low, and the weights are calculated finally. 1 leader can be selected only for half the weight

Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

Talk Zookeeper (one) analysis of the quorums mechanism of zookeeper--prevention of Split-brain problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.