Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The principle of watcher in Zookeeper

Shulou Source: shulou.com Published: 2022-06-02 08:21:28 10月03日 Update

This article mainly explains "the principle of watcher in Zookeeper". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the principle of watcher in Zookeeper".

Zookeeper provides an efficient and reliable distributed coordination service for distributed applications. Its implementation depends on the ZAB protocol and implements an architecture of active and standby mode to maintain the consistency of data in the cluster. Zookeeper enables distributed applications to be coordinated through a shared tree-structured namespace. It also stores all the data in memory. Any machine in the Zookeeper cluster can respond to the read operations of the client, and all the data exists in memory, so Zookeeper is more suitable for read-based application scenarios.

There are three roles in the cluster: leader,follower,observer. Leader is a machine determined by election, which provides read and write function for the client. Follower and observer can improve the read performance of the cluster without affecting the write performance. The number of Zookeeper cluster nodes is odd. There are three types of nodes: temporary node, persistent node and sequential node. Each node has a stat structure. The most important function is the watcher function.

Watcher:watcher is a core function in ZK. Watcher can monitor changes in the data of directory nodes and changes in subdirectories. Once these states change, the server will notify all watcher set on this directory node, so that each client will quickly know that the state of the directory node it is concerned about has changed and respond accordingly.

Its application scenarios include: unified naming service, cluster management, master election, distributed barrier and so on.

Open source clients are: zkclient, curator.

Https://my.oschina.net/u/3847203/blog/2878240

Thank you for your reading, the above is the content of "the principle of watcher in Zookeeper", after the study of this article, I believe you have a deeper understanding of the principle of watcher in Zookeeper, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Nodes clusters principles distribution functions customers data changes applications clients directories learning services memory content scenarios that is performance machines status Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information MySQL Shulou Technology Xiaomi