This is the 4th day of my participation in the August More Text Challenge
The CAP theorem in distribution actually means that in a distributed system, there must be three essential principles, which are:
Data Consistency service Availability Partition fault toleranceCopy the code
But it is not always possible to have all three, and today’s technology only addresses two of them.
The origin of
The CAP principle (theorem) was proposed by Eric Brewer at PODC 2000. The conjecture was proved to be true two years later and became the CAP theorem known to us now.
explain
In fact, these three principles are very close to our actual situation, and are often considered when designing distribution, but we will talk about them a little bit here.
Data Consistency: Consistency
Data consistency means that the distributed system is still in a consistent state after performing some atomic operation.
In distributed systems, the client must obtain the same value on any distributed node regardless of what operation is performed. This situation is known as the principle of data consistency in distributed systems.
The advantage is that there is no risk of data inconsistencies, and the disadvantage is that the efficiency is reduced as the newly modified operation is synchronized to each node each time. However, from the perspective of security, people will still follow data consistency, and the reduction of related efficiency can be tolerated.
Service Availability: Availability
Service availability means that every request always returns a result within a certain amount of time, meaning that every request should have a response, whether it is a failure or a success.
Tolerance: Partition tolerance
Fault tolerance of partitions refers to the fact that the system can still operate normally and provide responsive services regardless of information loss or failure.
application
At present, there is no way to achieve all of them, but only two of them can be realized, either AP or CP. ZooKeeper and Euraka are different ways in the technologies we usually use.
ZooKeeper: CP
ZooKeeper is implemented based on the master-slave model. At a certain point in time, only one master service provides interface services externally. If other services fail, a new one will be generated immediately to continue the service.
Euraka :AP
Euraka, on the other hand, is based on the equality model, without any hierarchy. When the client visits any node, it will give a response, and if the current node has a problem, the request will be transferred to other nodes.
However, this mode can not implement data consistency, generally through other ways to solve the problem of data consistency.