当前位置:网站首页>Distributed Theorem -- CAP theorem

Distributed Theorem -- CAP theorem

2021-09-15 08:06:05 jeremylai7

cap The theorem refers to , In a distributed system , Can only satisfy cap Two of them .
cap Theorem

C consistency Uniformity
A availability Usability
P partition tolerance Partition fault tolerance -- In case of any partition network failure, the system can still continue to operate

The Internet is not reliable , So you should support partition fault tolerance , And need to make a trade-off between software availability and consistency .

Why can't we satisfy C and A

  1. In general distributed systems, we must first ensure P( Partition fault tolerance )
  2. Consistency means that the data returned by all nodes is consistent
  3. Availability refers to the availability of the server within normal response time
  4. Suppose a distributed system has two services A and B, stay A Modify the user name of the service admin, Change to user
  5. If consistency is to be met , That is, the data returned by all nodes is consistent , visit B The service , stay A During data modification by the service , Need to lock B Service read and write operations , After the modification is completed A and B The service returns updated data , This does not guarantee availability ( Because there is a lock time ).
  6. If you want to ensure that you can , You cannot lock during data modification B Read and write operations of the service , After this modification ,A Return the updated data ,B Return old data , Does not satisfy consistency .

    application

  7. Uniformity

    • Data sensitive to data in the system , For example, the price of goods , stock , Consistency needs to be guaranteed , Discard availability .
  8. Usability

    • For data that is less sensitive to data , For example, the name of the product , The avatars , Nickname insensitive data , Availability needs to be guaranteed , Give up consistency .
    • Web page update

      Reference resources

  9. CAP The meaning of the theorem Ruan Yifeng

版权声明
本文为[jeremylai7]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/09/20210909134311747h.html

随机推荐