Zookeeper Application -- solving single point of failure in Distributed Systems

Source: Internet
Author: User
1. What is single point of failure in a distributed system? Generally, a distributed system uses the master-slave mode, that is, a master machine connects multiple processing nodes. The master node is responsible for distributing tasks, and the slave node is responsible for processing tasks. When the master node fails, the entire system will be paralyzed. We call this fault a single point of failure. Traditionally, a slave node is used. The slave node periodically sends a ping packet to the current master node. After receiving the ping packet, the master node sends an ACK reply to the slave node, when the slave node receives a response, it will think that the current master node is still alive and ask him to continue providing services. As shown in:

Image Description (50 words at most)

However, there is a hidden danger in this method, that is, the network problem. Let's look at the consequences of a network problem.

Image Description (50 words at most)

That is to say, our master node is not suspended, but the network fails during the reply, so that our slave node cannot receive the reply, and the master node will be suspended, then the slave node starts his master instance, so that two master nodes are available in our distributed system-dual master, after the dual master node appears, our slave node will report part of what it has done to the master node, and some will report to the slave node, so that the service is completely messy. To prevent this situation, we introduced zookeeper, which can ensure that there is only one master at all times, although it cannot avoid network faults. 2. After zookeeper is introduced, the zookeeper solution starts two master nodes: "master node-a" and "master node-B". After they start, they all register a node with zookeeper. Assume that "Master-a" locks the Registry node to "Master-00001", and "Master-B" registers the node to "Master-00002". After registration, the node is elected, the node with the smallest number will win in the election and get the lock to become the master node, that is, our "master node-a" will get the lock to become the master node, then, "master node-B" is blocked and becomes a slave node. In this way, the two master processes are scheduled.

Image Description (50 words at most)

If the "Master-a" node fails, the node registered with it will be automatically deleted, and zookeeper will automatically detect the node changes and send the election again, in this case, "master node-B" will win the election and replace "master node-a" to become the master node.

Image Description (50 words at most)

3. Master recovery

Image Description (50 words at most)

If the master node recovers, it will register a node with zookeeper again. At this time, the registered node will be "Master-00003", and zookeeper will detect node changes and initiate another election, at this time, "master node-B" will win again during the election and continue to serve as "master node", "master node-a" will serve as a slave node.

Zookeeper Application -- solving single point of failure in Distributed Systems

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.