Distributed theory CAP theorem

CAP principle, also known as CAP theorem means that in a distributed system, Consistency (consistency), Availability (availability), Partition tolerance (partitions fault tolerance), the three can not have both.

998, a computer scientist at the University of California, Eric Brewer proposed a distributed system has three indicators:

Consistency (Consistency): all data on the node to synchronize the time, strong consistency;
Availability (availability): each request can receive a response, regardless of whether the returned data match;
the Partition Tolerance (partition fault tolerance): the system should be able to continue to provide services, even in the face of a node failure or network partition.
They are the first letter C, A, P.
Eric Brewer said that the three indicators impossible at the same time. This conclusion is called CAP theorem.

The following were about under these three concepts:

1. Partition fault tolerance
with respect to the single-point systems, distributed systems will be deployed on multiple machines, there may be between the machines across the region, such as a server room in Beijing, one in Shanghai, the two rooms of if built between distributed systems, machine then the two regions is the need to communicate, but communication is likely to occur as long as the communication fails, the partition P is our fault-tolerant distributed system design must take into account the problem.

2. Consistency
Consistency is said to take data from a client in a distributed system, no matter from which machine the acquisition, should be up to date.

 

Assuming that a time client update to the server1 server vo-> v1, then no matter from server1 from server2 or values ​​are v1, so as to meet the consistency. And if cleint data written to server1, server2 to acquire from the value at this time has not been synchronized between server1 and server2, it will still get to vo, then do not meet the consistency.

3. Availability
Availability refers to, regardless of any time, client sends a request to Renyiyitai server, can get a response, regardless of the data obtained is v0 or v1.

The contradiction between consistency and availability

Because of the inevitability of partition P fault-tolerant, so consistency and availability A C can not be established at the same time.

 

If Server2 ensure consistency, it must Server1 on a write lock read and write operations to Server2. Only after data synchronization, to re-open to read and write. During the lock, Server2 can not read and write, so availability will not be met.

If Server2 to ensure the availability, you can not lock Server2, so consistency is not established.

In summary, Server2 consistency and availability can not be done at the same time. You can only select a target system design. If the pursuit of strong consistency, we can not guarantee the availability of all nodes; if the pursuit of availability of all nodes, it can not do strong consistency.

 

Published 60 original articles · won praise 1 · views 965

Guess you like

Origin blog.csdn.net/W_317/article/details/104449492