Recently, I quite often come across
this theorem . It has been proven for quite some time and a lot has been written about it. However, every time I stumble upon a distributed system that claims in the description of CA in terms of this theorem, i.e. the system in which Partition Tolerance is sacrificed for the sake of Consistency and Avalability, I hang up, since at least kill I can not imagine such a beast. After much deliberation, I nevertheless came to the conclusion that such a system is meaningless, which I want to discuss in this topic.
At the very beginning, let me remind you what each letter means in the abbreviations of the theorem. Although it is formulated for the general case of distributed systems, let's simplify the scope of consideration for distributed data storage systems to simplify. I want to clarify that the definition I give is not general, but very narrow, but so that it is easier for everyone to imagine.
- Consistency. Once we have successfully written data to our distributed repository, any client will receive this latest data when requested.
- Avalability. At any time, the client can get data from our repository, or get an answer about their absence, if no one has saved it yet.
- Partition Tolerance. The loss of messages between components of the system (perhaps even the loss of all messages) does not affect the performance of the system. Here a very important point is that if some components fail, then this also falls under this case, since it can be assumed that these components simply lose touch with the rest of the system.
The theorem says that if you build a distributed system, then you can satisfy only two of the above properties, i.e. definitely need to sacrifice one of the properties. The main issue that causes misunderstanding is what it means to donate Partition Tolerance. In the end, I came to the conclusion that it means saying goodbye to the guarantee that the system can function when the system is divided into areas between which any connection has disappeared, or simply when a certain set of components fall. Can you imagine a system that will be ready for it? Me not. In general, I'm not alone.
Here is a very interesting article about this. If I had not stumbled upon it, having come to the conclusion described above, I probably would not have written this topic, having decided that I simply did not understand something. After reading this article, which, by the way
, the author of the theorem himself approved , I nevertheless became convinced that there is something to talk about.
Thus, since it is impossible to sacrifice Partition Tolerance, for myself I formulate the CAP theorem as follows. When building a distributed system that could survive the failure of some of its components, it is necessary to sacrifice either availability (avalability) or consistency (consistency).
However, the question still arises: why then was the concept of Partition Tolerance introduced in this theorem? I think that in an ideal world where network, hardware and software failure cannot happen, it would be possible to build a CA system in which both availability and consistency would be at the same time. But as soon as we get into the real world, and some kind of failure happens, we immediately have to comply with Partition Tolerance and have to give up either full consistency or full accessibility. Well, or find some compromise, but to fully satisfy both properties will not succeed.
')
Update:
As stormy comments have shown, the biggest misunderstanding in the CAP-theorem (at least on my part) is the definition of the concept of Partition Tolerance, or rather, what it means to donate to them. As a result, I settled on counting under Partition Tolerance the property of a system to lose communication between components. Those. in the interpretation of the CAP-theorem, to abandon PT (which means to choose C and A) means that the system has an ideal connection and never loses communication between its parts. In this case, the wording sounds pretty clear.
References:
- You can not donate Partition Tolerance
- CAP theorem 12 years later: how the rules have changed
- Clarification of the CAP-theorem in the presence of errors
- One of the most popular links about the description of the CAP-theorem
- CAP-theorem simple, accessible language