“This is the 20th day of my participation in the August Gwen Challenge.
ZooKeeper is a distributed, open source distributed application coordination service. It is an open source implementation of Google’s Chubby and an important component of Hadoop and Hbase. It provides consistency services for distributed applications, including configuration and maintenance, domain name service, distributed synchronization, and group service.
Zookeeper positioning
Zookeeper is an open source apache Zookeeper project.
Main functions of Zookeeper
For micro-service distributed coordination management, metadata management,Master election, in actual use scenarios, mainly three types of projects
1. Applicable direction of ZooKeeper
(1) E-commerce management system based on Java at the back end
Zookeeper mainly works on distributed locks and registries. Zookeeper mainly maintains CP(consistency and partition fault tolerance) in CAP theory, that is to say, Zookeeper ensures strong consistency
② For big data storage, data management, master/slave data switch and other systems
Kafla, Canal, etc., which we are familiar with, are using metadata management of Zookeeper, electing specific master-slave through master,ZAB atomic consistency protocol,
③ Large Internet companies, self-developed distributed components
Generally based on ZooKeeper, ZooKeeper has been applied to major distributed systems, metadata management, and registries on a large-scale industrial scale, and is generally used in Dubbo + ZooKeeper to make a basic microservice architecture to achieve basic data calls
Summary:
The ZooKeeper distributed coordination system encapsulates all core and mainstream requirements and functions in the distributed architecture.
Distributed locking, metadata management, master elections, distributed coordination and notification
Zookeeper provides the following features:
Before understanding the basic architecture of ZooKeeper, let’s take a look at why ZooKeeper can realize coordination notification of distributed systems, metadata management, etc.
Those who are familiar with ZooKeeper stack are familiar with it. Zookeeper itself is in the notification coordination mechanism and has strong processing ability in data synchronization. That is why many self-developed frameworks use ZooKeeper at the bottom.
Background:
In a cluster environment, three physical machines are deployed in the ZooKeeper cluster.
1. Order consistency
Multiple requests, whether read or written, are executed sequentially; Zookeeper assigns a globally unique and incremented ZxID to each request to be processed internally// This unique global ID ensures sequence consistencyZxid = zxID = zxID = zxID = zxID = zxID = zxIDCopy the code
2. The atomicity
Either all machines succeed or all machines fail when synchronizing data operations// Ensure that the results of each synchronization operation are consistent
Copy the code
3. High availability
Cluster deployment prevents downtime. In case of downtime, you can also elect a leader to provide services again// From recovery mode to message broadcast mode
Copy the code
4. Data consistency:
In the case of clustering, the data on each machine is consistent. However, if there is a downtime during data synchronization, other machines will automatically save the data to the disk log. After the leader role is submitted, the data will be synchronized to the ZNode node, which truly realizes the data consistency on each machine// The data consistency here is a strong consistency and also the core feature of ZooKeeper. According to the CAP theory of distributed system maintenance, only CP can be supported.
// C-consistency for strong data consistency, P - for system partition fault tolerance, A- High availability, eureka supports AP features
Copy the code
5. High-performance
High performance, here proposed a ZooKeeper data model, ZNode node// ZNode nodes, pure memory based, fast, tree structure, similar to Linux file system, each node has dataThe stored data, already can handle the ability is relatively strong, will talk about it in detail later, continue to watch itCopy the code
Summary:
Zookeeper-based cluster architecture features: