Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the basic concept of Zookeeper

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the basic concept of 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 "what is the basic concept of Zookeeper".

What is Zookeeper?

Zookeeper is a typical distributed coordination service, based on which distributed applications can implement functions such as data publish / subscribe, load balancing, naming service, distributed coordination / notification, cluster management, Master election, distributed locking and distributed queue. Zookeeper guarantees the following distributed consistency characteristics:

Order consistency: transaction requests initiated from the same client must be applied to the Zookeeper in the order in which they are initiated

Atomicity: transactions must be all successful or all failed in the cluster. There is no case of partial success and partial failure.

Single view: connect to any server in the cluster and get the same data view

Reliability: once the server successfully executes a transaction, the change in the service state caused by the transaction will be permanently saved unless a new transaction updates its status

Real-time: real-time here does not mean that once the transaction is executed successfully, the client can get the latest data knot, but Zookeeper ensures that after a period of time, the latest data can be obtained.

The goal of Zookeeper

Simple data model: Zookeeper organizes data in numerical structure, similar to directory structure, each directory becomes ZNode in Zookeeper, and each ZNode can record a small amount of data.

You can build clusters: Zookeeper clusters are best built with odd numbers (more than half of the elections), and the two services in the cluster establish connections to communicate with each other.

Sequential access: all client update requests are assigned a globally unique ID (ZXID)

High performance: Zookeeper stores all data in memory, so the latency for read operations is very low.

The basic concept of Zookeeper Cluster role

There are three main roles in the Zookeeper cluster: Leader, Follower, and Observer. Leader is responsible for receiving the write request from the client and submitting the request to Follower for execution in a transactional manner. Follower is responsible for receiving read requests, participating in Leader elections, and more than half-writing success strategies. Observer is also responsible for receiving read requests and does not need to participate in the election of Leader and more than half of the success of writes. The main goal of this role is to expand the read performance of Zookeeper without affecting write performance.

Conversation

Session refers to the connection established between the client and the Zookeeper cluster. If the server connected to the client is down and can reconnect to another server without exceeding the sessionTimeout parameter setting, the previous session is valid.

Data node

In addition to the machine node, the data node here means that the ZNode,ZNode in Zookeeper is organized in the form of a file directory. There are two main forms: persistent nodes and temporary nodes. Once a persistent node is created, it will not be deleted unless it is manually removed. Temporary nodes are related to the lifecycle of the session, and temporary nodes created by session initiation are automatically deleted when the session is disconnected. Zookeeper can also set the SEQUENTIAL attribute for a node, and the node with this attribute is automatically created with a number after the node name, which is maintained by the parent node.

Version

Each ZNode of Zookeeper can store data, corresponding to each ZNode,Zookeeper maintains a data structure called Stat. Stat records three data versions of this ZNode, namely version (the current version of ZNode), cversion (the version of the current ZNode child node), and aversion (the current ACL version of ZNode).

Watch

Watch mechanism is a very important mechanism in Zookeeper. The client can register some Watcher on some ZNode, and when a specific event occurs, the Zookeeper server pushes the event to the interested client.

ACL

Zookeeper uses ACL policy for permission control, and has the following five permissions:

CREATE: permission to create child nodes

READ: permission to read node data and child node list

WRITE: permission to update node data

DELETE: delete permissions for child nodes

ADMIN: setting permissions for node ACL

Thank you for your reading, the above is the content of "what is the basic concept of Zookeeper". After the study of this article, I believe you have a deeper understanding of what the basic concept of Zookeeper is, 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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report