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 "how to understand CAP Theorem". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to understand CAP Theorem.
There are many high-end and difficult terms in the computer world, CAP is one of them, what consistency (Consistency), availability (Availability), partition fault tolerance (Partition tolerance) is very difficult to understand, coupled with the CAP theorem is even more confusing, today we try to interpret it popularly.
Zhang Dapang worked hard in the company and finally achieved the position of architect after years of efforts.
The architect's chair is not yet hot, and soon there is a project to do architectural design.
The boss called Da Pang and earnestly taught: big Pang, data is our precious asset, the system you designed must ensure that the data can not be lost ah!
Big fat said the boss rest assured, I have experience in this area, generally speaking, we have to do redundant processing of data, simply to make multiple copies of the data to save. I will design a distributed system to back up data to multiple machine nodes.
A few days later, Da Pang sent a picture showing how the distributed system works:
Data copies are redundant on different machines, and there is data replication in the middle to ensure the synchronization of data.
Although only two machines, it also constitutes a simple distributed environment.
Although the boss did not understand the technology, he was relieved to see that the data was backed up between different machines.
After several months of development and testing, the distributed system, which can accommodate thousands of people, went online smoothly, but we soon found that the distributed system is not as simple as the stand-alone system, due to network reasons, or a machine can easily lead to communication failure, or the node is not available.
One day, the user first visited machine An on the left and wrote a piece of data, and then machine A was unfortunately kicked off by the miserable network manager, which directly led to two serious consequences:
The load balancer could not find machine An and thought it was dead, so it was necessary to transfer the user's next visit to machine B.
Data replication could not find machine A, so it had to go on strike. The data just written by the user cannot be copied to machine B, which is still the old data.
What shall I do? Although this is an accident, just scold the network manager and plug it into the network cable, but who can guarantee that the communication between the two machines will be consistent and smooth?
Xiao Wang in the group said, "our machine B is still alive and can still provide services. if the data cannot be copied to machine B, we just look at a few pieces of data less, which is harmless, does not affect the overall situation, and is barely available. after plugging in the network cable, the data replication will work, and everything will return to normal."
Xiao Wang inadvertently chose the availability of the system (Availability, referred to as A), as long as the system can provide services, data inconsistencies can be tolerated.
Zhang Dafang said: no, the boss said that the data of our system is extremely important, and if the data is inconsistent, it will bring serious consequences, so the functions related to these key data on machine B must also be stopped, and we must wait until machine An is plugged into the network cable. Data synchronization can only be started.
Obviously, Zhang Dapang followed the instructions of his boss and put Consistency (C) in the first place.
So the problem is obvious, in the case of no communication between network nodes, the functions related to data replication can either choose availability (A) or consistent ©, not both.
Big fat thought carefully, in fact, there is another fact behind these two choices, that is, when the network nodes are unable to communicate, the nodes are isolated, resulting in network partitions, and the whole system can still work. Big fat gave it a name: partition fault tolerance (Partition tolerance, referred to as P).
If you choose availability (A) + partition fault tolerance (P), give up consistency (C).
If you choose consistency (C) + partition fault tolerance (P), you have to give up availability (A). In this case, although some functions of the system cannot be used because you need to wait for data synchronization, those functions that have nothing to do with data synchronization can still be accessed, which is equivalent to the functional degradation of the system.
Now that there are AP and CP, will there be a combination of just CA (consistency + usability)? That is, there is no partition fault tolerance, only availability and consistency are retained? If you think about it, this situation will actually degenerate into a stand-alone application, which is meaningless.
Fat feels as if he has found a rule: in a distributed computer system, consistency (C), availability (A) and partition fault tolerance (P) cannot be satisfied at the same time, at most two.
He decided to find a law called CAP Theorem, which sounded lofty and unfathomable.
If you really don't understand the CAP, Zhang Dapang will tell you a version that is easier to understand: in a distributed system, when nodes cannot communicate with each other (network partitions are generated), you can only choose availability or consistency, not both.
At this point, I believe you have a deeper understanding of "how to understand the 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.