In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
How to analyze CAP principle, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
It is estimated that most people have heard of the CAP theorem, but the practical value of the CAP theorem is rarely mentioned.
It is estimated that many people should mention the question of how to understand the help of the theorem to the actual operation and use.
Consistency, consistency
Availability availability
Fault tolerance of Partition tolerance Partition
But when many of my friends and I discussed this theorem, we actually had some different opinions, among which we had different understandings about C.
Consistency, consistency, this consistency, some people understand that data consistency is needed at the same time, and some people understand that data is consistent at the final moment.
Here I would like to give an example of what I understand C looks like.
For example, we have a car pre-sale system, while the car reservation is open for booking, and there are only 50 seats in the number. Well, according to the theorem of C, the data provided by our data A point write, B point read, C point read, due to the network failure between B and C, resulting in two clients, access to B and C nodes may get two completely different values at the same time, I personally think this is a serious violation of C, the theorem of consistency of this data. We need at a moment when the client accesses ABC and the data is consistent.
Availability An Availability
Basically, there are few people who have different opinions on this concept, and my personal understanding is that in a distributed system, any node that can continue to work must respond to the customer's request.
In the figure above, nodes An and B are the point of failure, and only node C is alive, which creates two problems. If C is to be available, it must be able to continue to provide services and provide services or responses. The response is contained in services consistent with nodes An and B, such as read or write services.
Fault tolerance of P Partition tolerance partitions
Let's just imagine that if there is a problem with the network, when A, B and C cannot be accessed each other, each node needs to access the client individually. Because of the network problem, the data of the A, B and C nodes will be inconsistent. Then whether our system can continue to work is a problem that needs to be considered in the fault tolerance of the partition.
So the next question is, what is the use of this theorem that I know?
First of all, it is necessary to know whether a database system is using the principle of CAP. If you know the principle of database use, you will have a clear understanding of the business corresponding to the database you are using.
There is a truth that I have learned recently that if you choose a database system only through perceptual choice, rather than based on the characteristics of the business, some embarrassing phenomena are likely to occur.
For example, we have a subtitle system that requires that as long as we can provide data, accuracy is not required, but continuous service is required.
Well, how do we think about C A P in such a system?
1C data consistency
2 An availability of data
Partition fault tolerance of 3p data
According to the above simple (perhaps not accurate second) requirements, we can roughly judge the system our database if according to the C A P principle we can provide the system way to ensure that, A, P
From the two points An and P that provide the service.
The main reason is that after entering subtitles, if we read from multiple nodes, we will ensure the provision of data, and we can continue to provide services when the network or other nodes fail, but what we cannot guarantee is the consistency of the data. if the customer writes data from node A, it is very likely that we will not be able to read the data at point B in the next second, or point C can already read the data. However, the data of point B and point C are not synchronized, which can be tolerated by this system.
And in line with the database described in our above system, the famous Cassandra is such a system, so you don't even want to use it on cassandra in a vain attempt to strictly read the same data at the same point in time. At the same time, if you understand this feature, you will know very well which systems cassarda will be applied to, and you will not dare to put cassardra into bank finance about payment. Used in systems such as collection.
And below if we still have related requirements, for example, we have a contract signing system, customers buy cars from us, and at the same time need to sign the contract and upload the electronic version of PDF as the final 4S store and the customer, the auto finance company, the tripartite legal file. What do we need to guarantee if we use distributed systems?
1 C consistency, 2 An availability 3 partition fault tolerance
According to the business, we can clearly understand that C consistency is what we need to guarantee. After uploading PDF documents from node A, we cannot find them in node B. The documents found in node C are inconsistent with node B. from a business point of view, this cannot be tolerated. At the same time, if there is a B node failure, then C node, A node can continue to provide related services.
What we lose is A, availability, and if we can't guarantee C, we will automatically terminate the service. It means that if we cannot guarantee that the information between the surviving nodes is C and consistent, then we should stop the service.
In database systems, for example, MONGODB is a system that supports CP, for example, we have a MONGODB with three nodes of replication sets, when our damaged nodes exceed most of the node's data, the system will terminate the related services.
At present, Apache KAFKA supports the CA system, but the key point in this system lies in where his log system is. If the master node that stores logs cannot synchronize network data with other nodes, then only the master node that stores logs can provide services, so the KAFKA system discards the attribute P.
So after understanding the principle of CAP, you can clearly understand what business you choose for what business, and what business should choose which system to support.
In the current situation of the vigorous development of distributed systems, for example, the MGR of MYSQL should be the product of the principle of CP (please let me know if you have any different opinions), the AWO of SQL SERVER is also a product of CP, and database products such as ORACLE are not part of the distributed database system so far.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.