当前位置:网站首页>Cap theory sounds very big, but it's actually very simple

Cap theory sounds very big, but it's actually very simple

2022-06-11 11:12:00 zhanyd

CAP The theory sounds very big , It's very simple .

Uniformity (Consistency): Make sure the data is consistent , Right

Usability (Availability): Ensure that the system can be used

Partition tolerance (Partition Tolerance): Even if the network goes wrong ( Partition ), I can bear

In distributed systems , The network is bound to go wrong , ineluctable , For example, the server hangs up , The program is up , The cable was kicked off , Network timeout and so on .

The servers were originally connected through the network , In one piece , In a large area , Synchronize data with each other , Now there is something wrong with the network , The servers are disconnected , They are isolated from each other , The data cannot be synchronized , This forms the partition .

A partition appears , We did, too , This is a network error , It's inevitable , So partition fault tolerance is P, It has always existed in distributed systems .

That's in P Under the premise of existence , We choose to guarantee : It is important that the data is correct (CP), It is more important to ensure that the system can be used (AP)?

CP: such as A The data of the server should be synchronized to B Server's , Now the network is down ,A The data can not be transmitted , I think it's important to guarantee the data , If A and B It's not right , The consequences are serious , In order to ensure A and B The data on the server is consistent , Just let A Stop the service , Return error information directly to the client , When the network is restored , Go online again , lest A and B The data are inconsistent .

AP: such as A The data of the server should be synchronized to B Server's , Now the network is down ,A The data can not be transmitted , I think it doesn't matter if the data are inconsistent temporarily , The most important thing is that the system can be used , Then I will continue to let A Provide services , When the network is restored , Resynchronize data to B.

CAP The problem is that the network is not working , We give priority to data consistency , The priority is to ensure the availability of the system .

 

 

 

原网站

版权声明
本文为[zhanyd]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111054046318.html