当前位置:网站首页>分布式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
边栏推荐
- js arguments参数使用和详解
- el-select如何实现懒加载(带搜索功能)
- buuctf-pwn write-ups (8)
- JSON web token -- comparison between JWT and traditional session login authentication
- Functions in C language (detailed explanation)
- Detectron:训练自己的数据集——将自己的数据格式转换成COCO格式
- (4) Canal multi instance use
- JS get the attribute values nested in the object
- Sword finger offer II 038 Daily temperature
- How much computing power does transformer have
猜你喜欢
Win10 clear quick access - leave no trace
1480. Dynamic sum of one-dimensional array
ES6 modularization
70000 words of detailed explanation of the whole process of pad openvino [CPU] - from environment configuration to model deployment
SQL injection - injection based on MSSQL (SQL Server)
BeanFactoryPostProcessor 与 BeanPostProcessor 相关子类概述
BUU-Crypto-[HDCTF2019]basic rsa
19. Framebuffer application programming
Arc135 C (the proof is not very clear)
AWT common components, FileDialog file selection box
随机推荐
Compound nonlinear feedback control (2)
px em rem的区别
How to clone objects
测试岗的中年危机该如何选择?是坚守还是另寻出路?且看下文
Understanding of cross domain and how to solve cross domain problems
Install pytoch geometric
How does apscheduler set tasks not to be concurrent (that is, execute the next task after the first one)?
1480. Dynamic sum of one-dimensional array
Error CVC complex type 2.4. a: Invalid content beginning with element 'base extension' was found. Should start with one of '{layoutlib}'.
BUU-Reverse-easyre
Kubernets first meeting
Arc135 a (time complexity analysis)
配置交叉编译工具链和环境变量
JSON Web Token----JWT和传统session登录认证对比
Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
Overview of relevant subclasses of beanfactorypostprocessor and beanpostprocessor
Penetration tool - sqlmap
Nexus 6p从8.0降级6.0+root
A little understanding of GSLB (global server load balance) technology
fastjson