In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the zookeeper architecture design and role division". The content of the article 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 zookeeper architecture design and role division".
In addition, follower and observer are both learner (learner) roles, and the division of learner is the state of synchronous leader.
Reading and writing of zookeeper
Each replication set node (follower,leader,observer) of zookeeper contains all the data in the cluster and is stored in memory, like an in-memory database. Update operations are logged to disk to ensure recoverability, and write operations are serialized to disk before being written to the in-memory database.
each ZooKeeper server serves the client. The client connects to only one server to submit the request. The read request is served by a local copy of each server database. Change the status of the service, and the request to write the request is handled by the zab protocol.
is part of the protocol, and all write requests from the client are forwarded to a single server called leader. The remaining ZooKeeper servers (called followers) receive message proposals from the leader leader and agree to the message delivery. The messaging layer is responsible for replacing the failed leader and synchronizing followers with the leader.
ZooKeeper uses the custom atomic messaging protocol zab. Because the messaging layer is atomic, when the leader receives a write request, it calculates the state of the system at the time of the application write and converts it into a transaction that captures this new state.
Zk's CAP principle
cap principle means that as a distributed system, there are at most two choices for consistency, availability and partition fault tolerance. That is, there must be a choice.
Consistency C
Zookeeper is a highly consistent system that synchronizes data very quickly. However, the data of each node cannot be guaranteed to be completely consistent without the sync () operation. In order to ensure consistency, zookeeper uses the zab protocol based on paxos protocol and tailor-made for zookeeper. What are these two agreements will be discussed in a later article.
Availability A (high availability and responsiveness)
Zookeeper data is stored in memory, and each node can read the request accordingly, so it has good response performance. Zookeeper ensures availability, data is always available, and there are no locks. And more than half of the nodes have the latest and real-time data.
Partition tolerance P
has two points to analyze.
Having too many nodes can lead to a very large write latency (more than half of the follower write commit is required) because multiple nodes are required to synchronize.
The Leader election with more nodes is very time-consuming and will magnify the problems of the network. This problem can be alleviated by introducing observer nodes.
Zookeeper's trade-off on the CAP issue
Strictly speaking, zk leaves the question of trade-offs to developers or users.
to coordinate CA (consistency and availability), users can choose whether or not to use the Sync () operation. The use ensures that all nodes are strongly consistent, but there will be a certain delay in synchronizing the data. On the other hand, if it is not necessary to ensure strong consistency, sync can not be used. Although the data synchronized by zookeeper is very fast, there is no way to ensure that the data of each node must be consistent, which users should pay attention to. In the actual development, it is necessary for the developer to make a choice according to the actual scenario, focusing more on consistency or usability.
In order to coordinate AP (consistency and scalability), users can choose whether to add obsever and the number of obsever. Observer is a new role in version 3.3.0 and will not participate in the election and voting process. The purpose is to improve the scalability of the cluster. Because the number of follower cannot be too large, follower needs to participate in the election and vote. if there is too much, the convergence rate of the election will be very slow, and the voting process will take a long time when writing the data. The addition of observer can improve usability and scalability. As the cluster can accept more client requests, usability will naturally improve, but the problem of consistency still exists, so it goes back to the trade-off problem of CA above.
Thank you for your reading, the above is the content of "what is the zookeeper architecture design and role division of labor". After the study of this article, I believe you have a deeper understanding of what the zookeeper architecture design and role division 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.