CAP

245 阅读1分钟

最近应该是要仔细看看两阶段提交,然后很多网上的文章就把我带到了 cap这里来。

只是听说过,然后简单知道很多技术是为了可用性(A),牺牲了一些一致性(C)。

P到底是?网络是不可靠的,所以P一定存在(分布式情况下)

一般会这么说,三者只能满足两个。那么我牺牲P,去满足CA可不可以?一百度果然有个人有同样的疑问 为什么CAP理论在舍弃P的情况下,可以有完美的CA?

看到的评论都是对cap理解有误。再看看这个。CAP理论中的P到底是个什么意思? 其中

we can interpret partition tolerance as meaning “a network partition is among 
the faults that are assumed to be possible in the system.” 
It is misleading to say that an algorithm “provides partition tolerance,” 
and it is better to say that an algorithm “assumes that partitions may occur.”

这么说吧。在分布式系统中P一定是存在的。因为网络不可靠。在网络不可靠的前提下,你只能满足C或者A其中一个。不可能CA都满足。

但是单机系统又不一样了,比如单机的mysql,这种系统就压根不涉及P。且他是能满足CA的,即在满足可用性的前提下,客户端写后,就能读到同样的数据。

这样这张知名的图片就理解了。

cap image