cap简介
c.biancheng.net中解释:reads and writes always succeed
Gilbert 和 Lynch 在论文中的描述是:every request received by a non-failing node in the system must result in a response
c.biancheng.net中解释:the system continues to operate despite arbitrary message loss or failure of part of the system
Gilbert 和 Lynch 在论文中的描述是:the network will be allowed to lose arbitrarily many messages sent from one node to another;
①网络分区
c.biancheng.net中解释:all nodes see the same data at the same time
Gilbert 和 Lynch 在论文中的描述是:any read operation that begins after a write operation completes must return that value, or the result of a later write operation
反证法:
如下图,假设cap成立,则必须支持p(系统必须支持容错② ),即只能选择cp或者ap。如果 clientA 发送到 server1 ,然后更新 client1,这是没问题的,但是 server2 由于网络、机器故障等原因无法及时更新 client2,此时如果要保证p,只有两种选择:
- 回退 server1 操作,即cp
- 允许此次执行,即ap
① 当网络发生异常导致分布式节点之间只有部分节点能进行通讯,这种现象称为网络分区,俗称脑裂
② 根据上面对p的解释,发现上图情况ca架构没法处理,只有挂掉,其实说明了p就是让系统拥有网络问题的处理机制,你不给p,那系统出现网络问题就不知道怎么执行,而网络处理机制要么就是c,要么就是a,亦证明了系统架构只能是cp或者ap