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 > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what is the principle of CAP". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Distributed systems (distributed system) are becoming more and more important, and large websites are almost all distributed.
The biggest difficulty of distributed system is how to synchronize the state of each node. CAP theorem is not only the basic theorem in this aspect, but also the starting point for understanding distributed systems.
This theorem is introduced in this paper. It's actually easy to understand, and it's obvious. The following content mainly refers to Michael Whittaker's article.
I. three indicators of distributed system
In 1998, Eric Brewer, a computer scientist at the University of California, proposed that there are three indicators for distributed systems.
Consistency
Availability
Partition tolerance
Their first letters are C, An and P, respectively.
Eric Brewer says it is impossible to achieve all three indicators at the same time. This conclusion is called CAP theorem.
II. Partition tolerance
Let's take a look at Partition tolerance, which is called "partition fault tolerance" in Chinese.
Most distributed systems are distributed in multiple subnetworks. Each subnetwork is called a partition. Partition fault tolerance means that interval communication may fail. For example, if one server is in China and the other is in the United States, these are the two zones that may not be able to communicate with each other.
Next, the user's read operation will get v1. It's called consistency.
In order to change G2 to v1, it is necessary to ask G1 to send a message to G2 during the G1 write operation, asking G2 to also change to v1.
IV. Availability
Availability is called "availability" in Chinese, which means that as soon as a user's request is received, the server must respond.
The user can choose to initiate a read operation to G1 or G2. No matter which server it is, as long as it receives a request, it must tell the user whether it is v0 or v1, otherwise it will not meet the availability.
5. The contradiction between Consistency and Availability
Why can't consistency and availability be established at the same time? The answer is simple because there may be communication failures and communication delays (that is, partition fault tolerance).
If the consistency of G2 is guaranteed, G1 must lock the read and write operations of G2 during write operations. Only after data synchronization can read and write be reopened. During lock-up, G2 cannot read or write, and there is no availability.
If the availability of G2 is guaranteed, it is inevitable that G2 cannot be locked, so consistency is not established.
To sum up, G2 cannot achieve consistency and availability at the same time. Only one target can be selected when designing the system. If you pursue consistency, you cannot guarantee the availability of all nodes; if you pursue the availability of all nodes, you cannot achieve consistency.
Readers ask, on what occasions does usability prevail over consistency?
For example, publish a page to CDN, and multiple servers have copies of the page. Later, an error was found and the web page needed to be updated, so it could only be updated once on each server.
In general, the update of a web page does not place special emphasis on consistency. Within a short period of time, some users get the old version, while others get the new version, so it won't be a big problem. Of course, everyone will see the new version eventually. So, in this case, usability is higher than consistency.
This is the end of the content of "what is the principle of CAP"? thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.