CAP定理-可用性和分区容限 [英] CAP theorem - Availability and Partition Tolerance

查看:130
本文介绍了CAP定理-可用性和分区容限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我尝试理解CAP中的可用性(A)和分区容限(P),但发现很难理解各种文章中的解释。

While I try to understand the "Availability" (A) and "Partition tolerance" (P) in CAP, I found it difficult to understand the explanations from various articles.

我感觉到A和P可以一起走(我知道情况并非如此,这就是为什么我不明白!)。

I get a feeling that A and P can go together (I know this is not the case, and that's why I fail to understand!).

简单解释一下,A和P是什么,它们之间的区别是什么?

Explaining in simple terms, what are A and P and the difference between them?

推荐答案

一致性意味着整个集群中的数据都是相同的,因此您可以从/向任何节点读取或写入数据,并获得相同的数据。

Consistency means that data is the same across the cluster, so you can read or write from/to any node and get the same data.

可用性意味着即使集群中的节点出现故障也可以访问集群。

Availability means the ability to access the cluster even if a node in the cluster goes down.

分区容限意味着即使两个节点之间的分区(通信中断)(两个节点都在上,但无法通信),群集仍可以继续工作。

Partition tolerance means that the cluster continues to function even if there is a "partition" (communication break) between two nodes (both nodes are up, but can't communicate).

为了获得可用性和分区容忍度,您必须放弃一致性。考虑在主-主设置中是否有两个节点X和Y。现在,X和Y之间的网络通信中断了,因此它们无法同步更新。此时,您可以:

In order to get both availability and partition tolerance, you have to give up consistency. Consider if you have two nodes, X and Y, in a master-master setup. Now, there is a break between network communication between X and Y, so they can't sync updates. At this point you can either:

A)允许节点不同步(放弃一致性),或者

A) Allow the nodes to get out of sync (giving up consistency), or

B)认为群集处于关闭状态(放弃可用性)

B) Consider the cluster to be "down" (giving up availability)

所有可用组合为:


  • CA -所有节点之间的数据都是一致的-只要所有节点都处于联机状态,并且您可以从任何节点读取/写入数据,并确保数据是相同的,但是如果您在节点之间开发了一个分区,则数据将不同步(一旦解决了分区,便不会重新同步)。

  • CP -所有节点之间的数据保持一致,并通过在节点发生故障时变得不可用来保持分区容限(防止数据不同步)。

  • AP >-节点即使无法彼此通信也将保持联机状态,并且一旦分区解决后将重新同步数据,但是不能保证所有节点都具有相同的数据(在运行期间或运行期间在分区之后)

  • CA - data is consistent between all nodes - as long as all nodes are online - and you can read/write from any node and be sure that the data is the same, but if you ever develop a partition between nodes, the data will be out of sync (and won't re-sync once the partition is resolved).
  • CP - data is consistent between all nodes, and maintains partition tolerance (preventing data desync) by becoming unavailable when a node goes down.
  • AP - nodes remain online even if they can't communicate with each other and will resync data once the partition is resolved, but you aren't guaranteed that all nodes will have the same data (either during or after the partition)

您应注意 CA系统实际上不存在(即使某些系统声称是这样)。

You should note that CA systems don't practically exist (even if some systems claim to be so).

这篇关于CAP定理-可用性和分区容限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆