This article introduces how to use Zookeeper. For more information, see
For more information, see the official zookeeper website.
Zookper: A Distributed Application collaboration Service
Zookper is a distributed, open-source collaborative service that is applied to distributed applications. It provides some simple operations so that distributed applications can implement services such as synchronization, configuration maintenance, and sharding or naming based on these interfaces. Zookper is easy to program, and uses a data model similar to the file tree structure. You can use Java or C for programming access.
As we all know, distributed system collaboration services are difficult to provide satisfactory products. These collaborative service products are prone to traps such as competitive selection conditions or deadlocks. Zookper aims to remove the need for collaborative services due to collaboration conflicts.
The design goal Zookeeper is simple.
Zookeeper uses a hierarchical namespace similar to the file system to allow distributed processes to work together. These namespaces are composed of a series of data registers, which are also called znodes. These znodes are like files and folders in the file system. Unlike the file system, files in the file system are stored in the storage area, while zookeeper data is stored in the memory. At the same time, this means that zookeeper has high throughput and low latency.
Zookeeper achieves high performance, high reliability, and orderly access. High Performance ensures that zookeeper can be applied to large-scale distributed systems. High reliability ensures that it will not cause any problems due to the failure of a single node. Ordered access ensures that the client can perform complex synchronization operations.
Zookeeper is reusable.
ZooKeeper Service
Each server that makes up Zookeeper must be able to communicate with each other. They save the server status, operation logs, and persistent snapshots in the memory. Zookeeper is available as long as most servers are available.
The client connects to a Zookeeper server and maintains the TCP connection. Send a request, get a response, get an event, and send a connection signal. If the TCP connection is disconnected, the client can connect to another server.
Zookeeper is ordered.
Zookeeper uses numbers to mark each update. This ensures the order of Zookeeper interaction. Subsequent operations can implement more abstract services such as synchronization operations in this order.
Zookeeper is efficient
Zookeeper is more efficient than read-oriented systems. Zookeeper performs well in a distributed system with a read/write ratio of about on thousands of servers.
Data Structure and hierarchical namespace
The structure of the Zookeeper namespace is similar to that of the file system. A path with the same name as a file. Each node of zookeeper is uniquely identified by a path.
ZooKeeper's Hierarchical Namespace
Implementation
Displays the advanced component services of the ZooKeeper service. In addition to the request processor, each server in the Zookeeper server group copies each of their own components.
ZooKeeper Components
Replicated database is a structure stored in the memory that contains the entire data tree. All update operations are logged to the hard disk. In addition, write operations are serialized and stored on the hard disk when the database is used.
Each ZooKeeper server connects to many clients. The client connects to a server to submit the request.