当前位置:网站首页>分布式CAP理论
分布式CAP理论
2022-07-04 06:01:00 【詹Sir(开源字节)】
CAP理论是分布式系统、特别是分布式存储领域中被讨论的最多的理论。其中C代表一致性 (Consistency),A代表可用性 (Availability),P代表分区容错性 (Partition tolerance)。CAP理论告诉我们C、A、P三者不能同时满足,最多只能满足其中两个。
CAP 理论简介
CAP理论是分布式系统、特别是分布式存储领域中被讨论的最多的理论。其中C代表一致性 (Consistency),A代表可用性 (Availability),P代表分区容错性 (Partition tolerance)。CAP理论告诉我们C、A、P三者不能同时满足,最多只能满足其中两个。

CAP 三选二
一致性 (Consistency): 一个写操作返回成功,那么之后的读请求都必须读到这个新数据;如果返回失败,那么所有读操作都不能读到这个数据。所有节点访问同一份最新的数据。可用性 (Availability): 对数据更新具备高可用性,请求能够及时处理,不会一直等待,即使出现节点失效。分区容错性 (Partition tolerance): 能容忍网络分区,在网络断开的情况下,被分隔的节点仍能正常对外提供服务。
对CAP理论的理解
理解CAP理论最简单的方式是想象两个副本处于分区两侧,即两个副本之间的网络断开,不能通信。
- 如果允许其中一个副本更新,则会导致数据不一致,即丧失了C性质。
- 如果为了保证一致性,将分区某一侧的副本设置为不可用,那么又丧失了A性质。
- 除非两个副本可以互相通信,才能既保证C又保证A,这又会导致丧失P性质。
一般来说使用网络通信的分布式系统,无法舍弃P性质,那么就只能在一致性和可用性上做一个艰难的选择。
CAP理论的表述很好地服务了它的目的,开阔了分布式系统设计者的思路,在多样化的取舍方案下设计出多样化的系统。在过去的十几年里确实涌现了不计其数的新系统,也随之在一致性和可用性的相对关系上产生了相当多的争论。
CAP理论深入理解
在CAP理论提出十二年之后,其作者又出来辟谣。“三选二”的公式一直存在着误导性,它会过分简单化各性质之间的相互关系:
- 首先,由于分区很少发生,那么在系统不存在分区的情况下没什么理由牺牲C或A。
- 其次,C与A之间的取舍可以在同一系统内以非常细小的粒度反复发生,而每一次的决策可能因为具体的操作,乃至因为牵涉到特定的数据或用户而有所不同。
- 最后,这三种性质都可以在程度上衡量,并不是非黑即白的有或无。可用性显然是在0%到100%之间连续变化的,一致性分很多级别,连分区也可以细分为不同含义,如系统内的不同部分对于是否存在分区可以有不一样的认知。
所以一致性和可用性并不是水火不容,非此即彼的。Paxos、Raft等分布式一致性算法就是在一致性和可用性之间做到了很好的平衡的见证。
如若转载,请注明出处:开源字节 https://sourcebyte.cn/article/176.html
边栏推荐
- BUU-Crypto-[GUET-CTF2019]BabyRSA
- Google Chrome browser will support the function of selecting text translation
- How to expand all collapse panels
- 复合非线性反馈控制(二)
- Programmers don't talk about morality, and use multithreading for Heisi's girlfriend
- webrtc 快速搭建 视频通话 视频会议
- Excel comparator
- transformer坑了多少算力
- left_and_right_net可解释性设计
- What are the reasons for the frequent high CPU of ECS?
猜你喜欢

C语言练习题(递归)

A little understanding of GSLB (global server load balance) technology

What are the reasons for the frequent high CPU of ECS?

Review | categories and mechanisms of action of covid-19 neutralizing antibodies and small molecule drugs

HMS v1.0 appointment.php editid参数 SQL注入漏洞(CVE-2022-25491)

win10清除快速访问-不留下痕迹
![[untitled]](/img/32/cfd45bb5e8555ea2ad344161370dbe.png)
[untitled]

如何实现视频平台会员多账号登录
![[microservice] Nacos cluster building and loading file configuration](/img/50/7af220c57a06eb186729c9882d9dab.png)
[microservice] Nacos cluster building and loading file configuration

Grounding relay dd-1/60
随机推荐
冲击继电器JC-7/11/DC110V
Sword finger offer II 038 Daily temperature
接地继电器DD-1/60
Thinkphp6.0 middleware with limited access frequency think throttle
我的NVIDIA开发者之旅——优化显卡性能
How to configure static IP for Kali virtual machine
AWT introduction
"In simple language programming competition (basic)" part 1 Introduction to language Chapter 3 branch structure programming
ES6 modularization
How to get the parent node of all nodes in El tree
JS how to convert seconds into hours, minutes and seconds display
Take you to quickly learn how to use qsort and simulate qsort
BUU-Real-[PHP]XXE
Yiwen unlocks Huawei's new cloud skills - the whole process of aiot development [device access - ESP end-to-side data collection [mqtt]- real time data analysis] (step-by-step screenshot is more detai
C语言中的函数(详解)
How to expand all collapse panels
Programmers don't talk about morality, and use multithreading for Heisi's girlfriend
509. 斐波那契数、爬楼梯所有路径、爬楼梯最小花费
QT releases multilingual International Translation
2022.7.2-----leetcode. eight hundred and seventy-one