当我试图理解CAP中的“Availability”(A)和“Partition tolerance”(P)时,我发现很难理解各种文章的解释。
我有一种感觉,a和P可以同时出现(我知道事实并非如此,这就是我不能理解的原因!)
简单地解释一下,什么是A和P以及它们之间的区别?
当我试图理解CAP中的“Availability”(A)和“Partition tolerance”(P)时,我发现很难理解各种文章的解释。
我有一种感觉,a和P可以同时出现(我知道事实并非如此,这就是我不能理解的原因!)
简单地解释一下,什么是A和P以及它们之间的区别?
当前回答
简单的CAP定理指出,分布式系统不可能同时提供所有三个保证:
一致性
每个节点同时包含相同的数据
可用性
每次必须至少有一个节点可用以提供数据
分区容忍
系统的故障是非常罕见的
大多数情况下,每个系统只能保证至少两个特性:CA、AP或CP。
其他回答
将P与C和A等同看待是一个错误,而C、A、P之间的“三选二”概念是具有误导性的。我解释CAP定理的简洁方式是,“在分布式数据存储中,在网络分区时,你必须在一致性或可用性中选择一个,并且不能两者兼得”。新的NoSQL系统正试图关注可用性,而传统的ACID数据库则更关注一致性。
你真的不能选择CA,网络分区不是任何人都想要的,它只是分布式系统的一个不受欢迎的现实,网络可能会失败。问题是,当这种情况发生时,你如何权衡你的应用程序。第一个提出这个术语的人的这篇文章似乎很清楚地解释了这一点。
一致性——当我们发送读请求时,如果它正在返回结果,它应该返回客户端请求给出的最近的写。 可用性—您的读/写请求应该总是成功的。 分区容忍度——当网络分区(某些机器相互通信的问题)发生时,系统仍然可以工作。
在分布式环境中,存在网络分区发生的可能性,我们无法避免CAP的“P”。因此,我们在“一致性”和“可用性”之间进行选择。
http://bigdatadose.com/understanding-cap-theorem/
理解CAP定理的简单方法:
In case of network partition, one needs to choose between perfect availability and perfect consistency. Picking consistency means not being able to answer a client's query as the system cannot guarantee to return the most recent write. This sacrifices availability. Picking availability means being able to respond to a client's request but the system cannot guarantee consistency, i.e., the most recent value written. Available systems provide the best possible answer under the given circumstance.
这个解释来自这篇优秀的文章。希望能有所帮助。
根据上图C是断开的,但A,B, D可以继续工作。现在我们可以调用系统部分工作(分区容忍)。
假设一个特定的事务只需要a、B和d,系统可以执行它而不会产生任何不一致。
但是当C必须参与一个特定的事务时,系统可以以两种方式执行。
1.由于C不可用,A可以拒绝用户请求。
So the system has Partition-Tolerance and consistency (P,C).
But no availability, because of the rejection.
2.A可以将C接收到的消息保存在A的本地内存中,并在C连接回来时传输。
So the system has Partition-Tolerance and availability (P,A).
But no consistency.because C has not updated.
Brewer's keynote, the Gilbert paper, and many other treatments, places C, A and P on an equal footing as desirable properties of an implementation and effectively say 'choose two!'. However, this is often considered to be a misleading presentation, since you cannot build - or choose! - 'partition tolerance': your system either might experience partitions or it won't. CAP is better understood as describing the tradeoffs you have to make when you are building a system that may suffer partitions. In practice, this is every distributed system: there is no 100% reliable network. So (at least in the distributed context) there is no realistic CA system. You will potentially suffer partitions, therefore you must at some point compromise C or A.
https://github.com/henryr/cap-faq#10-why-do-some-people-get-annoyed-when-i-characterise-my-system-as-ca