In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 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 meaning of CAP Theorem". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "what is the meaning of CAP Theorem"?
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.
In the figure above, G1 and G2 are two servers that span regions. G1 sends a message to G2, which may not be received. This situation must be taken into account when designing the system.
Generally speaking, partition fault tolerance is unavoidable, so it can be considered that the P of CAP is always true. The CAP theorem tells us that the rest of C and A cannot be done at the same time.
III. Consistency
Consistency is called "consistency" in Chinese. It means that this value must be returned for the read operation after the write operation. For example, if a record is v0, the user initiates a write operation to G1 and changes it to v1.
Next, the user's read operation will get v1. It's called consistency.
The problem is that it is possible for the user to initiate a read to G2 and return v0 because the value of G2 has not changed. The results of G1 and G2 read operations are inconsistent, which is not consistent.
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.
In this way, the user can also get v1 by initiating a read operation to G2.
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 communication may fail (that is, partition fault tolerance occurs).
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.
At this point, I believe you have a deeper understanding of "what is the meaning of CAP Theorem". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.