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 is the concept of web distributed system CAP

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "what is the concept of web distributed system CAP". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the concept of web distributed system CAP".

Introduction

CAP is the most discussed theory in distributed systems, especially in the field of distributed storage. "what is CAP Theorem?" Rank FAQ's No.1 under the Quora distributed system category. CAP also has a wide range of popularity among programmers, it is not only "C, A, P can not be satisfied at the same time, at most 3 can only choose 2", the following try to synthesize the point of view of all parties, from the perspective of development history, engineering practice and other aspects of CAP theory. I hope you can know more about CAP theory through this article.

CAP theorem

CAP [1] [2] was put forward by Eric Brewer at the 2000 PODC conference, which is the conjecture about data consistency (consistency), service availability (availability) and partition fault tolerance (partition-tolerance) obtained by Eric Brewer during the development of search engine and distributed web cache during Inktomi [3]:

It is impossible for a web service to provide the three following guarantees: Consistency, Availability and Partition-tolerance.

This conjecture was proved to be true two years after it was put forward, and became the well-known CAP theorem.

Data consistency (consistency): if the system returns success for a write operation, then subsequent read requests must read the new data; if the return fails, then all read operations cannot read the data, and the data has strong consistency (strong consistency) for the caller (also known as atomic atomic, linear consistency linearizable consistency) [5]

Service availability (availability): all read and write requests are answered within a certain period of time, can be terminated and do not wait all the time

Partition fault tolerance (partition-tolerance): in the case of a network partition, the separated nodes can still serve the outside world normally.

If the AP is satisfied at a certain time, and the separated nodes can not communicate with each other at the same time, the state will be inconsistent, that is, C cannot be satisfied; if the CP is satisfied, the request can only wait for C in the case of network partition, that is, A can not be satisfied; if the CA is to be satisfied, the node state can be consistent within a certain period of time, and the network partition cannot be satisfied.

C, An and P can only satisfy two of them at most. Like FLP theorem, CAP theorem also indicates an unreachable result (impossibility result).

Engineering Enlightenment of CAP

Seven or eight years after CAP theory was put forward, NoSql circle regarded CAP theory as the basis against traditional relational database and clarified the correctness of relaxing the requirement of data consistency (consistency). Then it caused a wide range of discussion about CAP theory.

CAP theory seems to give us a choice of 3 to 2, but there are many practical restrictions in engineering practice, which need us to do more consideration and tradeoff to avoid entering the misunderstanding of CAP [7].

1. The understanding of P

Partition literally means network partition, that is, the system is divided into several separate parts due to network factors. Some people may say that the probability of network partition is very small, so it is not necessary to consider P and guarantee CA [8]. To understand P, let's look back at the definition of P in CAP proof [4]:

In order to model partition tolerance, the network will be allowed to lose arbitrarily many messages sent from one node to another.

The situation of network partition conforms to this definition, and the case of network packet loss also conforms to the above definition. In addition, if the node is down, the packets sent by other nodes to the down node will also be lost, which is also consistent with the definition. In reality, we are faced with an unreliable network and devices with a certain probability of downtime, both of which will lead to Partition, so P is a must in distributed system implementation, not an option [9] [10].

For distributed system engineering practice, CAP theory is more appropriate to describe that no algorithm can satisfy both data consistency and service availability on the premise of partition fault tolerance [11]:

In a network subject to communication failures, it is impossible for any web service to implement an atomic read/write shared memory that guarantees a response to every request.

2. The selection of CA non-0Compact 1.

P is a required option, so the multiple choice questions of 3 to 2 will not become data consistency (consistency) and service availability (availability) 2 to 1? In engineering practice, there are different degrees of consistency and different levels of usability. Under the premise of ensuring the fault tolerance of partitions, consistency and availability can be taken into account after relaxing constraints.

The consistency in the proof of CAP theorem refers to strong consistency, which requires that the tuned composed of multiple nodes can operate like a single node, the operation is atomic, and the data are required in time and time sequence. If these requirements are relaxed, there are other types of consistency:

Sequence consistency (sequential consistency) [13]: sequence consistency is not required. Operation A precedes operation B. after operation B, if all end-reading operations get the result of operation A, sequence consistency is satisfied.

Final consistency (eventual consistency) [14]: relax the time requirement, and at a certain point after the operation response is completed, the data of multiple nodes are finally agreed.

Usability means that all read and write operations must be terminated in CAP Theorem. In practical applications, usability has different meanings from two different perspectives: subject and tuned. When P (network partition) appears, the tone can only support read operations and achieve data agreement at the expense of partial availability.

In engineering practice, a more common approach is to use asynchronous copy copy (asynchronous replication) and quorum/NRW to achieve the effect that the data is strong consistent in the caller, the tuned end is finally consistent, the service is available to the caller, and the tuned end allows some nodes to be unavailable (or separated by the network) [15].

3. Jump out of CAP

CAP theory has guiding significance for the implementation of distributed systems, but CAP theory does not cover all the important factors in distributed engineering practice.

For example, latency is an important indicator to measure system availability and is directly related to user experience [16]. The usability in CAP theory requires that the operation can be terminated and not be carried out endlessly. in addition, we are also concerned about how long it will take to end the operation, which is the delay, which is worthy of our separate consideration when designing and implementing distributed systems.

Delay and data consistency is also a pair of "enemies", if you want to achieve strong consistency, multiple copies of data consistent, it is bound to increase the delay. With the consideration of delay, we get a modified version of CAP theory PACELC [17]: if P (network partition) appears, how to choose between A (service availability) and C (data consistency); otherwise, how to choose between L (delay) and C (data consistency).

Thank you for reading, the above is the content of "what is the concept of web distributed system CAP". After the study of this article, I believe you have a deeper understanding of what the concept of web distributed system CAP is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Development

Wechat

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

12
Report