Distributed System features: in CAP, we use examples from original villagers to describe the concept of three elements in the distributed system. In this section, I will introduce several features that should be addressed in distributed systems. CAP1Consistency (consistency) 2 Availability (Availability) 3 distributed system features: CAP
In the previous section, we used examples of villagers in the original village to illustrate the concept of three elements in the distributed system. In this section, I will introduce several features that should be addressed in distributed systems.
CAP
1. Consistency (Consistency)
2. Availability (Availability)
3. Partition tolarance (Partition fault tolerance)
Consistency means that two or more nodes need to work together to complete a business logic. this business logic cannot store intermediate states in a permanent state. In other words, the business logic should either succeed on each node or fail on each node. For example, if a matchmaker wants to promote a marriage, she must first go to the home of both men and women to do work. As long as one of the two sides does not agree with this affair, the whole incident needs to be voided. If you agree to this affair, the matchmaker will be able to successfully promote this marriage. Assume that the man's family has agreed, but the matchmaker has not asked the woman, the matchmaker will not tell the man, "you can arrange a new house now", instead, I will say, "I will ask this question at the woman's house ". When the woman's house asks this question, if the woman's house agrees, the matchmaker will ask both parties to get married. If the woman does not agree, the matchmaker will have to go to the man's house to talk about the matter and give up the marriage.
Availability means that no matter what situation you encounter, whether you can send a message to me, whether it is successful or failed. This is like writing letters to others. if a recipient has a good habit and replies to each letter, you will feel that such a person is very reliable and the system is the same.
Partition fault tolerance means that the system can continue to work, even if data is lost or partially failed. Each node has its own metadata information or persistent information required by the cluster, but the system is risky. each node may cause data loss due to special circumstances, if the data of a node is lost, whether the cluster can recover the data correctly and provide services normally means that the partition is fault tolerant. (Here we have to think about it. if there are two nodes with errors at the same time, if there are three nodes, if there are n nodes ).
We have once proved that the above three cannot be both at the same time, so we need to pay attention to the trade-offs and trade-offs.
The following is a translation article about the combination of CAP and the appropriate scenarios.
Http://robertgreiner.com/2014/08/cap-theorem-revisited/
Consistency: read requests ensure that the latest data is returned.
Availability: a node that is not suspended can return a reasonable result within a limited period of time.
Partition Tolerance: when the network between nodes is split, the system can still provide services. (The system will continue to function when network partitions occur)
Before further explanation, we need to explain one thing first. Object-oriented programming! = Network programming. During programming, we assume that several programs with shared memory may be split into one or more regions in the case of unstable networks, that is, the data of these programs may be inconsistent. In distributed computing, the most important thing is that the network is reliable. The network is by no means reliable. The network is often unavailable and congested. Network problems often occur inadvertently. Due to network instability, you must partition in a distributed system to be fault tolerant. The following describes whether your choice is more Availability or Consistency when partitioning.
CP: Consistency/Partition Tolerance-errors may occur while waiting for a node to return information. Of course, the system can return errors, or do not return errors, and work on another copy. In this case, you need to determine whether to select Availability or Consistency based on the business logic. If the data to be displayed must be the latest submitted data, select the Consistency mode. In this case, an error is reported instead of switching to the copy. As follows:
AP: Availability/Partition Tolerance-In this mode, the latest data you return may be outdated for users. choosing Availability instead of Consistency depends on your business needs, your business needs to focus more on stability and tolerate a small number of inconsistencies. The system wants to run rather than simply report errors. As shown in: