当前位置:网站首页>分布式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
边栏推荐
- Wechat applet +php realizes authorized login
- AWT introduction
- Use of hutool Pinyin tool
- Tutle clock improved version
- Leetcode question brushing record | 206_ Reverse linked list
- Penetration tool - sqlmap
- Input displays the currently selected picture
- Thinkphp6.0 middleware with limited access frequency think throttle
- How to avoid JVM memory leakage?
- buuctf-pwn write-ups (8)
猜你喜欢
My NVIDIA developer journey - optimizing graphics card performance
BUU-Pwn-test_ your_ nc
[Excel] 数据透视图
Detectron: train your own data set -- convert your own data format to coco format
Impact relay jc-7/11/dc110v
Actual cases and optimization solutions of cloud native architecture
Halcon image calibration enables subsequent image processing to become the same as the template image
Functions in C language (detailed explanation)
Kubernets first meeting
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
随机推荐
AWT介绍
High performance parallel programming and optimization | lesson 02 homework at home
[Excel] 数据透视图
Error CVC complex type 2.4. a: Invalid content beginning with element 'base extension' was found. Should start with one of '{layoutlib}'.
复合非线性反馈控制(二)
FRP intranet penetration, reverse proxy
Json Web token - jwt vs. Traditional session login Authentication
HMS v1.0 appointment. PHP editid parameter SQL injection vulnerability (cve-2022-25491)
Kubernets first meeting
The end of the Internet is rural revitalization
检漏继电器JY82-2P
Upper computer software development - log information is stored in the database based on log4net
C语言中的函数(详解)
Programmers don't talk about morality, and use multithreading for Heisi's girlfriend
How to avoid JVM memory leakage?
js获取对象中嵌套的属性值
Introduction to AMBA
2022.7.2-----leetcode. eight hundred and seventy-one
MySQL的information_schema数据库
Tutle clock improved version