To understand what ZooKeeper is, we need to start with why it exists. Take distributed system architecture as an example.
Early we are single application architecture, with the rapid development of Internet and increasing volume, the backend architecture by means of vertical scaling is hard to achieve our desired performance requirements, and input-output ratio is very big also, at the same time, ordinary PC performance is becoming more and more high, so to improve performance by means of horizontal scaling became the mainstream.
Under the distributed architecture, when the service is becoming more and more scale is more and more big, the corresponding machine number also is more and more big, the artificial alone to management and maintenance services and address configuration information will be more and more difficult, the problem of single point of failure also began to stand out, once the service routing or load balancing server (Nginx) downtime, depend on him all the service will fail.
At this point, you need a place to dynamically register and obtain service information. To manage the service name and its corresponding server list information in a unified manner, it is called service configuration center. When starting up, service providers register the service name and server address provided by them in the service configuration center, and service consumers obtain the machine list of services to be invoked through the service configuration center. Based on the corresponding load balancing algorithm, select one of the servers to call. When the server goes down or offline, the corresponding machine needs to be able to dynamically removing from the service configuration center, and inform the corresponding service consumers, service consumers will likely errors occur because of the service call to have failed, in the process, service consumers only need to look when the first call to service center of service configuration, The queried information is cached to the local server. Subsequent calls directly use the locally cached service address list information without re-initiating a request to the service configuration center to obtain the corresponding service address list until the service address list changes (the machine goes online or offline). This decentralized structure solves the problem of single points of failure caused by load balancing equipment and greatly reduces the pressure on the service configuration center.
So we need a middleware framework to solve this problem, and summarize the above requirements for this framework:
1. Decentralized, non-centralized (see above for understanding) 2. High availability 3. Capable of load balancing algorithms.
And that’s where ZooKeeper came in.
Zookeeper is an open source distributed coordination service created by Yahoo! And an open source implementation of Google Chubby. Zookeeper is designed to encapsulate complex and error-prone distributed consistency services into an efficient and reliable set of primitives.
Here I feel that as long as you can say exactly what distributed coordination services are coordinating, you can make it clear.
Conclusion:
Zookeeper provides efficient and reliable distributed coordination services for distributed applications. Its implementation relies on the ZAB protocol and implements a master-slave server architecture to maintain data consistency. Zookeeper itself ensures the consistency of distributed data and provides efficient and reliable coordination services.
As a distributed coordination service, Zookeeper provides distributed basic services such as unified naming service, configuration management, and distributed lock. Zookeeper uses a consistency protocol called ZAB(Zookeeper Atomic Broadcast) instead of Paxos algorithm to solve the problem of distributed data consistency.
ZK is an open source implementation of Google’s Chubby, a distributed lock service based on the PaxOS algorithm. Due to its high availability and consistency, ZK can be used for many system services: load balancing, naming services, distributed locks, cluster management, master elections, etc., are all coordination services improved by ZK.