In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what is the difference between Zookeeper and Eureka". The content in 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 the difference between Zookeeper and Eureka".
CAP theorem
In the development of distributed systems, nothing is more influential than CAP theorem, which is the theoretical cornerstone of the development of distributed systems.
Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community
In 2000, Eric Brewer, a computer scientist at the University of California, proposed the CAP conjecture.
In 2002, Seth Gilbert and Nancy Lynch of the Massachusetts Institute of Technology theoretically proved CAP's conjecture and CAP's conjecture became CAP's theorem.
"CAP Theorem, to put it simply, is that distributed systems cannot meet the three elements of Consistency consistency, Availability availability and Partition Tolerance partition fault tolerance at the same time."
Consistency consistency
Consistency means that the data returned by accessing any node is consistent at any time of the node. That is, after the client side writes a data, the server synchronizes the data to the whole system, thus ensuring that the data of the system is the same.
Availability availability
Usability means that the cluster can respond to the user's request.
Fault tolerance of Partition Tolerance partitions
The meaning of partition fault tolerance is that when a partition failure occurs, the system still has to provide services. In the distributed system, each service node is unreliable. when some nodes are abnormal, or when the communication between the nodes is abnormal, the partition problem occurs in the whole system, and the partition problem exists objectively in the distributed system.
CAP tradeoff
CA
The system chooses CA, that is, it does not support partition fault tolerance, only consistency and availability. It means that partition anomalies are not allowed and the network is in an ideal state. However, the network anomaly between distributed systems exists objectively. If P is avoided, the distributed system can only be returned to a single instance system.
CP
Because the distributed system P exists objectively, we have to choose between CP and AP.
When the network partition occurs, there is no communication between the two distributed nodes, and our modifications to one node will not be synchronized to the other, so the "consistency" of the data will not be satisfied. because the data of the two distributed nodes are no longer consistent. Unless we sacrifice the "availability", that is, suspend the distributed node service, when the network partition occurs, we will no longer provide the function to modify the data, and continue to provide services until the network condition fully returns to normal.
When choosing CP, it is tantamount to giving up the availability of the system in exchange for consistency. Zookeeper is a system that chooses CP.
In a zookeeper cluster, there are three roles
The role acts as the sole scheduler and handler of Leader transaction requests (transaction requests are requests other than queries) Follower handles non-transaction requests, participates in Leader election voting Observer handles non-transaction requests, and does not participate in election voting
When the Leader server fails, a new server is re-elected as the Leader server from the Follower server. Transaction requests are suspended during the re-election of the Leader server and will not be executed until after the election of the Leader server. That is, in order to ensure consistency, the availability of the system is abandoned.
AP
When choosing AP, it is tantamount to giving up system consistency in exchange for availability. Eureka is a system that chooses AP.
Different from the three roles in the zookeeper cluster, each node in the eureka cluster plays the same role. They sense the existence of each other by registering each other, and when there is registration information, they will synchronize to other nodes in the cluster.
Let me analyze how eureka gives up consistency to ensure availability from the point of view of the source code (rest assured, the source code will not be released, give me a general idea. The source code is also relatively simple. If you are interested, you can read my blog https://blog.csdn.net/zzti_erlie/article/details/104088914).
Information about the eureka registry is stored in the member variables of the AbstractInstanceRegistry class
/ / AbstractInstanceRegistry private final ConcurrentHashMap registry = new ConcurrentHashMap ()
Even a double-layer map, this double-layer map is also easy to understand. The outermost layer is the service name, and inside is a specific instance name
When a service registers with eureka, the registration information is saved in map and synchronized to other nodes. At this point, it is possible that some nodes are unavailable, or the network is down, and no information is received, and the information in the cluster nodes may be inconsistent.
When a client fails to get information from one eureka node, or fails to register, it automatically switches to another eureka node. As long as an eureka node is available, the registration service is available.
The difference between Zookeeper and Eureka
Finally, summarize the difference between the two.
ZookeeperEureka design principles CPAP advantages and disadvantages final consistent data high availability disadvantages during the election of leader the data between the cluster unavailable service nodes may be inconsistent applicable scenarios require higher data consistency and higher registry service availability thank you for your reading, this is the content of "what is the difference between Zookeeper and Eureka", after the study of this article I believe that we have a deeper understanding of what is the difference between Zookeeper and Eureka, 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.