Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the knowledge points related to distributed CAP

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what are the knowledge points related to distributed CAP". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the knowledge points related to distributed CAP"?

The past Life and present Life of CAP

1.1 Origin

CAP theory, jokingly known as "hat theory", CAP is an idea put forward by Eric Brewer at the 2000 ACM seminar: "consistency, usability, and partition fault tolerance cannot be satisfied at the same time in distributed systems, and only two of them can be satisfied at most!"

In 2002, Seth Gilbert and Nancy Lynch proved the conjecture by using the anti-positive method: "if the three can be satisfied at the same time, then because the existence of P is allowed, there must be packet loss between Server, so there is no guarantee of C." In this proof, the definition of CAP is more clearly stated.

C: consistency is called an atomic object, and any read or write should appear to be "atomic" or serial. The read after writing must be able to read what was written before, and all read and write requests seem to be sorted globally.

A: any non-failed node should give a response to the request within a limited time. (termination of the request)

P: allow any number of messages to be lost between nodes, and when a network partition occurs, messages between nodes may be completely lost.

However, it only proves that the three CAP can not be satisfied at the same time, and does not prove that any two can be satisfied; so the proof is considered to be a narrowed result and has been questioned in the following 10 years.

1.2 reinterpretation

In 2012, Brewer and Lynch responded to all the questions by reinterpreting CAP. The expression "2 out of 3" is inaccurate and works smoothly in some areas where it rarely happens. CAP occurs not only in the whole system, but also in a subsystem or at a certain stage of the system. Limit the proof of CAP theory to scenarios of atomic read and write, and state that scenarios such as database transactions are not supported. The consistency scenario does not introduce the user agent, but only occurs in the background cluster. Partition fault tolerance boils down to a statement of the network environment rather than a previous independent condition. Liveness and safety are introduced to study distributed systems under a more abstract concept, and CAP is considered to be a special case of the tradeoff between activity and security attributes. The consistency belongs to liveness and the availability belongs to safety.

There are synchronization and partial synchronization in the network; the result of consistency also changes from only one to N (partially consistent); the communication period round is introduced to ensure N consistent results.

Summary: narrow the applicable definition of CAP, eliminate the questioning scenario, and show the broad research results of CAP under non-single consistent results.

Analysis of CAP

2.1 composition

Consistency: consistency

Availability: availability

Partition tolerance: partition tolerance

2.2 Consistency

From the point of view of the paper: the read operation after the operation must return this value.

From an encyclopedia point of view: whether all data backups in a distributed system have the same value at the same time.

Summary: in a distributed system, C represents anyone who accesses any data at any place and at any time and the results are consistent.

2.3 Availability

From the point of view of the paper: as long as the user's request is received, the server must respond.

From the encyclopedia: after the failure of some nodes in the cluster, whether the cluster as a whole can still respond to the read and write requests of the client.

Summary: in a distributed system, A stands for services that are available and accessible at all times.

2.4 Partition tolerance

From the point of view of the paper, the literal translation is called "partition fault tolerance", which means that interval communication may fail.

From an encyclopedia point of view: zoning is equivalent to the time limit for communication.

Summary: partition fault tolerance = partition + fault tolerance. Because of the multi-instance deployment, the distributed system is faced with the demand of network communication among multiple subnetworks, and the unreliability of network communication results in the existence of partitions. The existence of partitions will inevitably lead to data and availability problems, which need to be dealt with by fault-tolerant mechanism.

Practical analysis

3.1 the difference between An and P

From the above description, because both have fault-tolerant descriptions, it is easy to confuse A with P. Next, we analyze the differences between C and P from various dimensions.

1. From the point of view of concern, An is concerned with the users' requirements for the availability of distributed systems, while P is concerned with network connectivity between distributed system instances.

2. From the perspective of requirements, A requires that the distributed system be always available within the normal response time from an external perspective; P from the perspective of instance nodes, when a node or communication failure occurs between nodes, the distributed system as a whole is required to be fault-tolerant and resilient to the nodes.

3. From the perspective of audience, An is for users and P is for service examples.

3.2 CP and AP

The combination of the three produces three combinations: AC, AP and CP. However, in the distributed environment, multi-instance deployment is the basic condition, because of the unreliability of the network, P has become a hard condition. So the result is transformed into two branches: CP and AP.

The branches of CP and AP represent hard conditions, and the essential problem of this branch is to pursue benefits on this basis. If it is rude to give up another option directly, then the world is too simple, easy, and does not meet our expectations and basic use of the system. This is the final state meaning of the reinterpretation of CAP in 2012. "three choices and two" is a pseudo-proposition.

Based on the ultimate meaning of 2012 CAP, we find that CP is not simply to give up A, but to guarantee the hard conditions of CP to pursue A. Therefore, there is a very classical way of using more than half of the writes: after more than half of the writes, the distributed nodes can complete the data consistency requirements according to the minority obeying the majority. As a result, it produces the greatest benefit.

1. The higher availability of distributed instances is considered successful if all instances are not written successfully.

2. For the faster response of distributed instances, broadcast is used to quickly obtain more than half of the results and then directly identify the results. Rely on supplementary means to achieve data consistency.

After talking about the change of CP, let's talk about the corresponding adjustment and upgrade of AP. We give up the consistency of data in order to be highly available, in fact, this statement is not rigorous and wrong. Data consistency is the basic requirement of the system. So how to understand AP, in terms of dirty reading and phantom reading, the scenario allows temporary inconsistency of data and accepts the ultimate consistency of data.

1. The rigor of data is a requirement of the system, but allowing a certain delay of data is the meaning of the existence of AP.

2. The high availability of the system can satisfy more groups, from this goal, so AP is more friendly.

Because of the distributed system, the system is multifaceted and combined, so we will not say whether a system is AP or CP. We choose CP and AP according to the business scenario of the system, but high availability is the characteristic of Internet distributed applications, so we pursue AP in most cases and try our best to make the system meet more users. Then CP is selected based on the need for strong consistency of some scenario data.

Summary

In the distributed environment, the requirements of cap. Whether cp or ap, it is not a matter of discarding the other completely, but a matter of priority; to pursue another one on the basis of satisfying C or A, the conclusions are as follows:

1. CP-- pursues usability on the bottom line of strong consistency (case-more than half write).

2. AP- pursues data consistency (case-final consistency) on the basis of high availability.

3. The system is based on AP, and CP is used to supplement in some scenarios with high real-time and consistency of data.

At this point, I believe you have a deeper understanding of the "distributed CAP-related knowledge points", you might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report