Home > Article > Backend Development > Detailed explanation of usage based on Zookeeper_PHP tutorial
For more information, please check the zookeeper official website
Zookper: a collaboration service for distributed applicationsZookper is a distributed, open source, collaboration service for distributed applications. It provides some simple operations so that distributed applications can implement services such as synchronization, configuration maintenance, and clustering or naming based on these interfaces. Zookper is easy to program and uses a data model similar to a file tree structure. Programming access can be done using Java or C.
As we all know, it is difficult to produce satisfactory products for distributed system collaboration services. These collaborative service products can easily fall into traps such as competing selection conditions or deadlocks. The purpose of Zookper is to eliminate the need for distributed services to implement additional collaboration services due to collaboration conflicts.
Design Goal Zookeeper is simpleZookeeper allows distributed processes to work with each other through a hierarchical namespace similar to a file system. These namespaces consist of a series of data registers, which we also call znodes. These znodes are a bit like files and folders in a file system. Unlike the file system, the files of the file system are stored in the storage area, while the 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 ordered access. High performance ensures that zookeeper can be applied to large distributed systems. High reliability ensures that it will not cause any problems due to the failure of a single node. Orderly access can ensure that the client can implement more complex synchronization operations.
Zookeeper is reusableZooKeeper Service
The servers that make up Zookeeper must be able to communicate with each other. They store server state in memory, log operations, and persist snapshots. As long as most servers are available, Zookeeper is available.
The client connects to a Zookeeper server and maintains a TCP connection. And send requests, get replies, get events, and send connection signals. If the TCP connection is disconnected, the client can connect to another server.
Zookeeper is orderlyZookeeper uses numbers to mark each update. This ensures orderly Zookeeper interactions. Subsequent operations can implement higher and more abstract services such as synchronization operations based on this sequence.
Zookeeper is efficientThe efficiency of Zookeeper is even more reflected in read-oriented systems. Zookeeper can perform well on a distributed system composed of thousands of servers with a read-write ratio of approximately 10:1.
Data structures and hierarchical namespacesThe structure of Zookeeper's namespace is very similar to that of a file system. A path is represented by the same / as the file name. Each node in zookeeper is uniquely identified by the path
ZooKeeper's Hierarchical Namespace
AchievementThe following figure shows the high-level component services of the ZooKeeper service. In addition to the request handler, each server in a ZooKeeper server group replicates each component of their own.
ZooKeeper Components
The replicated database is a structure containing the entire data tree stored in memory. All update operations are logged to the hard disk. And the write operation will be serialized and stored on the hard disk when it is applied to the database.
Each ZooKeeper server is connected to many clients. Clients connect to a server to submit requests.