Home  >  Article  >  what is cap

what is cap

青灯夜游
青灯夜游Original
2021-03-18 16:11:1338837browse

cap stands for CAP principle or CAP theorem, which refers to the fact that in a distributed system, the three elements of consistency, availability, and partition tolerance can only occur at the same time at most. To achieve two things, it is impossible to take care of all three.

what is cap

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

The CAP principle, also known as the CAP theorem, refers to the fact that in a distributed system, Consistency, Availability, and Partition tolerance cannot be achieved simultaneously.

Consistency (C): All data backups in the distributed system have the same value at the same time. (Equivalent to all nodes accessing the same latest copy of data)

Availability (A): Ensure that every request has a response regardless of success or failure.

Partition tolerance (P): The loss or failure of any information in the system will not affect the continued operation of the system.

The essence of the CAP principle is that it is either AP, CP, or AC, but there is no CAP. If there is no copy of data in a distributed system, then the system must meet the strong consistency condition, because there is only unique data, and there will be no data inconsistency. At this time, the two elements C and P are present, but if a network failure occurs in the system Partition status or downtime will inevitably lead to some data being inaccessible. At this time, the availability conditions cannot be met, that is, in this case, the CP system is obtained, but the CAP cannot be satisfied at the same time.

Therefore, when designing a distributed architecture, trade-offs must be made. Currently, system performance is generally improved through the eventual consistency of each node in the distributed cache, and clustered data consistency is achieved by using asynchronous data replication technology between multiple nodes. NOSQL like memcached is usually used as a means of implementation. Although memcached can also be in a distributed cluster environment, a piece of data is always stored on a certain memcached server. If a network failure occurs or the server crashes, all data stored on that server will be inaccessible. Since data is stored in memory, restarting the server will cause all data to be lost. Of course, you can also implement a mechanism yourself to synchronize and persist data between distributed memcached, but it is very difficult to implement.

For more programming related knowledge, please visit: Programming Video! !

The above is the detailed content of what is cap. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn