Distributed system CAP theorem

What is the CAP theorem?

C:

Consistency [ kənˈsɪstənsi ], concentration; coherent; consistent; consistent (Baidu translation).

So, C means consistency. However, the consistency here represents strong consistency, that is, the update operation is a transaction, and all nodes will be updated at the same time.

A:

Availability[ əˌveɪlə'bɪlətɪ ], effective; beneficial; availability; something available (Baidu translation).

So, A stands for availability. That is, all request operations can be responded normally.

P:

Partition tolerance,Partition tolerance; Partition fault tolerance; Partition tolerance; (Baidu translation).

What exactly does partition fault tolerance mean? See: P of CAP

Before reading the following, you must understand what each of C, A, and P stands for, and you must think about it.

After understanding the above, let's talk about the CAP theorem: in a distributed system, at most two of the consistency, availability, and partition fault tolerance can be satisfied at the same time .

Why?

Distributed distributed, then the first thing to ensure is partition fault tolerance, so we talk about the premise of partition fault tolerance, say CA

Suppose the distributed system has two nodes, m and n. Under the normal operation of the system, the m and n nodes both have x=1 in the initial situation. When a user requests to reach A, it is necessary to modify x=2.

When the m node modifies x to 2, it will tell the n node to also modify x to 2 through a network request. After m and n are modified, the A node will want to respond to the user that the modification is completed.

However, since m and n communicate through the network, what about the network before m and n is broken? Or is the n service down?

There is no way for m to tell n to change x to 2. At this time, if A (availability) is still guaranteed, it responds to the user's request and tells that x has been changed to 2. Since m cannot contact n, there is no way to notify n to change x. If it is 2, it will cause data inconsistency, that is, C (consistency) cannot be guaranteed; on the contrary, if m has to wait for the network connection with n to tell n to change x to 2, there is no way to respond to the user, the user It will wait until it times out, which is not normal, i.e. A (availability) is not guaranteed.

It has been explained above that either AP cannot be C, or CP cannot be A. As for CA cannot be P, you can understand after thinking about it.

Because if you want to ensure data consistency and availability, you can only put the data on the server's own node, so there is no partition fault tolerance.









Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325939442&siteId=291194637