Skip to content

Commit

Permalink
完善 CAP 理论
Browse files Browse the repository at this point in the history
  • Loading branch information
Snailclimb committed May 28, 2021
1 parent 513258a commit 966faca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/system-design/distributed-system/CAP理论.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ CAP 理论的提出者布鲁尔在提出 CAP 猜想的时候,并没有详细
>
> 简而言之就是:CAP 理论中分区容错性 P 是一定要满足的,在此基础上,只能满足可用性 A 或者一致性 C。
因此,**分布式系统理论上不可能选择 CA 架构,只能选择 CP 或者 AP 架构。**
因此,**分布式系统理论上不可能选择 CA 架构,只能选择 CP 或者 AP 架构。** 比如 ZooKeeper、HBase 就是 CP 架构,Cassandra、Eureka 就是 AP 架构,Nacos 不仅支持 CP 架构也支持 AP 架构。

**为啥无同时保证 CA **
**为啥不可能选择 CA 架构呢** 举个例子:若系统出现“分区”,系统中的某个节点在进行写操作。为了保证 C, 必须要禁止其他节点的读写操作,这就和 A 发生冲突了。如果为了保证 A,其他节点的读写操作正常的话,那就和 C 发生冲突了。

举个例子:若系统出现“分区”,系统中的某个节点在进行写操作。为了保证 C, 必须要禁止其他节点的读写操作,这就和 A 发生冲突了。如果为了保证 A,其他节点的读写操作正常的话,那就和 C 发生冲突了。
**选择 CP 还是 AP 的关键在于当前的业务场景,没有定论,比如对于需要确保强一致性的场景如银行一般会选择保证 CP 。**

**选择的关键在于当前的业务场景,没有定论,比如对于需要确保强一致性的场景如银行一般会选择保证 CP **
另外,需要补充说明的一点是: **如果网络分区正常的话(系统在绝大部分时候所处的状态),也就说不需要保证 P 的时候,C 和 A 能够同时保证**

### CAP 实际应用案例

Expand Down

0 comments on commit 966faca

Please sign in to comment.