Depth explanation, distributed middleware Zookeeper

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_39662660/article/details/99481871

 

 

1, Zookeeper Profile

Zookeeper is consistent with a high-performance distributed systems has been widely used in distributed systems. Based on it, you can achieve distributed synchronization, configuration management, namespace management and many other functions, it is a common base system distributed system.

Zookeeper is mainly used to solve the consistency problem of distributed application systems in the cluster, which has a tree structure of nodes, each node can be a small amount of data storage. At the same time, the user can modify the content and subscription node. Distributed system nodes by monitoring changes in the state of the data, which can achieve the cluster based on the management data.

From the standpoint of design patterns, Zookeeper mode is implemented based on the observer. We can use it as a center of information. Using the service to producers and consumers of data Zookeeper basis. which is:

  • Zookeeper producer may change the node or data node
  • Zookeeper consumers through subscription node, which can receive a notification when a node changes

 

Based on this mechanism, the Zookeeper as an information center, will be able to achieve eventual consistency node distributed system state.

2. Features

Zookeeper has the following characteristics:

  • Eventual consistency: the client regardless of which is connected to a node which Zookeeper, will receive a copy of the same state. This is the most important performance zookeeper.
  • Reliability: Zookeeper clusters having a simple, strong, good performance, if the message m is accepted to a server, it will be acceptable to all the server.
  • Timeliness: Zookeeper ensure client server update information obtained in a range of time intervals, or the information server failure. However, due to network delay and other reasons, Zookeeper not guarantee that two client can simultaneously receive data just updated, the latest data if needed, should call sync before reading data () interface.
  • Waiting is not (wait-free): slow or failure of the client shall not interfere with the client's request quickly, so that each client can effectively wait.
  • Atomicity: Update only success or failure, no intermediate state.
  • Sequence: the partial order and includes a global ordered two types: global order means that if a release message before the message b in a server, a message will be posted on the message before all b Server; partial order means that if a message b Post same after a message sender, a row in front of bound b.

 

3, zookeeper scenarios

  • Publish and subscribe data: application configuration to focus on the nodes, the initiative to obtain application startup, and registered a watcher on the nodes, each configured to update the application will notice.
  • Name space services: the distributed naming service, create a node, the node's path is globally unique, it can be used as a global name.
  • Distributed notification / coordination: Different systems are listening to the same node, has been updated once, another system can be notified.
  • Distributed Lock: Zookeeper ensure strong data consistency, any time the user can trust the data for each node in the cluster are the same. A user creates a node as a lock, another user of the detection node, if present, on behalf of the other user has locked, if not, you can create a node on behalf of has a lock.
  • Cluster Management: Each of the machines are added to the cluster to create a node, write their own state. Users monitor the parent node will be notified the appropriate treatment. Delete nodes leave, parent monitor users will also be notified. Figure:

 

 

 

  • 配置管理:在分布式应用环境中很常见,例如同一个应用系统需要多台节点运行,但是它们运行的应用系统的某些配置项是相同的,如果要修改这些相同的配置项,那么就必须同时修改每台运行这个应用系统的 PC Server,这样非常麻烦而且容易出错。像这样的配置信息完全可以交给 Zookeeper 来管理,将配置信息保存在 Zookeeper 的某个目录节点中,然后将所有需要修改的应用机器监控配置信息的状态,一旦配置信息发生变化,每台应用机器就会收到 Zookeeper 的通知,然后从 Zookeeper 获取新的配置信息应用到系统中。如图:

 

Guess you like

Origin blog.csdn.net/qq_39662660/article/details/99481871