Skip to content

Commit 7dae89c

Browse files
committed
[docs add]Gossip 协议详解
1 parent 8c48313 commit 7dae89c

File tree

11 files changed

+42
-24
lines changed

11 files changed

+42
-24
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,10 @@ JVM 这部分内容主要参考 [JVM 虚拟机规范-Java8 ](https://docs.oracle
327327

328328
### 理论&算法&协议
329329

330-
- [CAP 理论和 BASE 理论解读](./docs/distributed-system/theorem&algorithm&protocol/cap&base-theorem.md)
331-
- [Paxos 算法解读](./docs/distributed-system/theorem&algorithm&protocol/paxos-algorithm.md)
332-
- [Raft 算法解读](./docs/distributed-system/theorem&algorithm&protocol/raft-algorithm.md)
330+
- [CAP 理论和 BASE 理论详解](./docs/distributed-system/theorem&algorithm&protocol/cap&base-theorem.md)
331+
- [Paxos 算法详解](./docs/distributed-system/theorem&algorithm&protocol/paxos-algorithm.md)
332+
- [Raft 算法详解](./docs/distributed-system/theorem&algorithm&protocol/raft-algorithm.md)
333+
- [Gossip 协议详解](./docs/distributed-system/theorem&algorithm&protocol/gossip-protocl.md)
333334

334335
### API 网关
335336

docs/.vuepress/sidebar.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,12 @@ export const sidebarConfig = sidebar({
430430
text: "理论&算法&协议",
431431
icon: "suanfaku",
432432
prefix: "theorem&algorithm&protocol/",
433-
children: ["cap&base-theorem", "paxos-algorithm", "raft-algorithm"],
433+
children: [
434+
"cap&base-theorem",
435+
"paxos-algorithm",
436+
"raft-algorithm",
437+
"gossip-protocl",
438+
],
434439
},
435440
"api-gateway",
436441
"distributed-id",

docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-in-action.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# ZooKeeper 实战
1+
---
2+
title: ZooKeeper 实战
3+
category: 分布式
4+
tag:
5+
- ZooKeeper
6+
---
27

38
这篇文章简单给演示一下 ZooKeeper 常见命令的使用以及 ZooKeeper Java客户端 Curator 的基本使用。介绍到的内容都是最基本的操作,能满足日常工作的基本需要。
49

docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-intro.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
2-
3-
# ZooKeeper 相关概念总结(入门)
1+
---
2+
title: ZooKeeper 相关概念总结(入门)
3+
category: 分布式
4+
tag:
5+
- ZooKeeper
6+
---
47

58
相信大家对 ZooKeeper 应该不算陌生。但是你真的了解 ZooKeeper 到底有啥用不?如果别人/面试官让你给他讲讲对于 ZooKeeper 的认识,你能回答到什么地步呢?
69

docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-plus.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# ZooKeeper 相关概念总结(进阶)
1+
---
2+
title: ZooKeeper 相关概念总结(进阶)
3+
category: 分布式
4+
tag:
5+
- ZooKeeper
6+
---
27

38
> [FrancisQ](https://juejin.im/user/5c33853851882525ea106810) 投稿。
49
@@ -90,7 +95,7 @@
9095

9196
![3PC流程](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/80854635d48c42d896dbaa066abf5c26~tplv-k3u1fbpfcp-zoom-1.image)
9297

93-
> 这里是 `3PC` 在成功的环境下的流程图,你可以看到 `3PC` 在很多地方进行了超时中断的处理,比如协调者在指定时间内为收到全部的确认消息则进行事务中断的处理,这样能 **减少同步阻塞的时间** 。还有需要注意的是,**`3PC``DoCommit` 阶段参与者如未收到协调者发送的提交事务的请求,它会在一定时间内进行事务的提交**。为什么这么做呢?是因为这个时候我们肯定**保证了在第一阶段所有的协调者全部返回了可以执行事务的响应**,这个时候我们有理由**相信其他系统都能进行事务的执行和提交**,所以**不管**协调者有没有发消息给参与者,进入第三阶段参与者都会进行事务的提交操作。
98+
> 这里是 `3PC` 在成功的环境下的流程图,你可以看到 `3PC` 在很多地方进行了超时中断的处理,比如协调者在指定时间内未收到全部的确认消息则进行事务中断的处理,这样能 **减少同步阻塞的时间** 。还有需要注意的是,**`3PC``DoCommit` 阶段参与者如未收到协调者发送的提交事务的请求,它会在一定时间内进行事务的提交**。为什么这么做呢?是因为这个时候我们肯定**保证了在第一阶段所有的协调者全部返回了可以执行事务的响应**,这个时候我们有理由**相信其他系统都能进行事务的执行和提交**,所以**不管**协调者有没有发消息给参与者,进入第三阶段参与者都会进行事务的提交操作。
9499
95100
总之,`3PC` 通过一系列的超时机制很好的缓解了阻塞问题,但是最重要的一致性并没有得到根本的解决,比如在 `PreCommit` 阶段,当一个参与者收到了请求之后其他参与者和协调者挂了或者出现了网络分区,这个时候收到消息的参与者都会进行事务提交,这就会出现数据不一致性问题。
96101

docs/distributed-system/theorem&algorithm&protocol/cap&base-theorem.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: CAP & BASE理论详解
33
category: 分布式
44
tag:
5-
- 分布式协议&算法
5+
- 分布式理论
66
---
77

88
经历过技术面试的小伙伴想必对 CAP & BASE 这个两个理论已经再熟悉不过了!

docs/distributed-system/theorem&algorithm&protocol/gossip.md docs/distributed-system/theorem&algorithm&protocol/gossip-protocl.md

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
2-
title: CAP & BASE理论详解
2+
title: Gossip 协议详解
33
category: 分布式
44
tag:
55
- 分布式协议&算法
6+
- 共识算法
67
---
78

89
## 背景
@@ -31,7 +32,9 @@ Gossip 协议最早是在 ACM 上的一篇 1987 年发表的论文 [《Epidemic
3132

3233
## Gossip 协议应用
3334

34-
**1、Redis Cluster 基于 Gossip 协议通信共享信息**
35+
NoSQL 数据库 Redis 和 Apache Cassandra、服务网格解决方案 Consul 等知名项目都用到了 Gossip 协议,学习 Gossip 协议有助于我们搞清很多技术的底层原理。
36+
37+
我们这里以 Redis Cluster 为例说明 Gossip 协议的实际应用。
3538

3639
我们经常使用的分布式缓存 Redis 的官方集群解决方案(3.0 版本引入) Redis Cluster 就是基于 Gossip 协议来实现集群中各个节点数据的最终一致性。
3740

@@ -54,14 +57,6 @@ Redis Cluster 的节点之间会相互发送多种 Gossip 消息:
5457

5558
关于 Redis Cluster 的详细介绍,可以查看这篇文章 [Redis 集群详解(付费)](https://javaguide.cn/database/redis/redis-cluster.html)
5659

57-
**2、NoSQL 数据库 Apache Cassandra 集群通过 Gossip 协议来进行动态管理集群节点状态(节点故障检测和恢复)。**
58-
59-
**3、服务网格解决方案 Consul 使用 Gossip 协议网络内可靠有效地传输新服务和事件的信息。**
60-
61-
**4、Bitcoin 使用 Gossip 协议来传播交易和区块信息。不过,为了提供更好的隐私保护,CMU 的研究人员提出 蒲公英协议。**
62-
63-
还有非常多使用 Gossip 协议的应用,学习 Gossip 协议有助于我们搞清很多技术的底层原理。
64-
6560
## Gossip 协议消息传播模式
6661

6762
Gossip 设计了两种可能的消息传播模式:**反熵(Anti-Entropy)****传谣(Rumor-Mongering)**
@@ -95,7 +90,7 @@ Gossip 设计了两种可能的消息传播模式:**反熵(Anti-Entropy)**
9590
3. 节点 C 推送数据给 A,节点 A 获取到节点 B,C 中的最新数据。
9691
4. 节点 A 再推送数据给 B 形成闭环,这样节点 B 就获取到节点 C 中的最新数据。
9792

98-
虽然反熵很简单实用,但是,节点过多或者节点动态变化的话,反熵就不太适用了。这个时候,我们想要实现最终一致性就要靠 **谣言传播(Rumor mongering) **
93+
虽然反熵很简单实用,但是,节点过多或者节点动态变化的话,反熵就不太适用了。这个时候,我们想要实现最终一致性就要靠 **谣言传播(Rumor mongering)**
9994

10095
### 谣言传播(Rumor mongering)
10196

docs/distributed-system/theorem&algorithm&protocol/paxos-algorithm.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
2-
title: Paxos 算法详细
2+
title: Paxos 算法详解
33
category: 分布式
44
tag:
55
- 分布式协议&算法
6+
- 共识算法
67
---
78

89
## 背景

docs/distributed-system/theorem&algorithm&protocol/raft-algorithm.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Raft 算法详解
33
category: 分布式
44
tag:
55
- 分布式协议&算法
6+
- 共识算法
67
---
78

89
> 本文由 [SnailClimb](https://github.com/Snailclimb)[Xieqijun](https://github.com/jun0315) 共同完成。

docs/home.md

+2
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ JVM 这部分内容主要参考 [JVM 虚拟机规范-Java8 ](https://docs.oracle
331331
- [CAP 理论和 BASE 理论解读](./distributed-system/theorem&algorithm&protocol/cap&base-theorem.md)
332332
- [Paxos 算法解读](./distributed-system/theorem&algorithm&protocol/paxos-algorithm.md)
333333
- [Raft 算法解读](./distributed-system/theorem&algorithm&protocol/raft-algorithm.md)
334+
- [Gossip 协议详解](./distributed-system/theorem&algorithm&protocol/gossip-protocl.md)
335+
334336

335337
### API 网关
336338

docs/java/new-features/java17.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void testFooBar(String s) {
139139

140140
删除远程方法调用 (RMI) 激活机制,同时保留 RMI 的其余部分。RMI 激活机制已过时且不再使用。
141141

142-
## JEP 409密封类(转正)
142+
## JEP 409:密封类(转正)
143143

144144
密封类由 [JEP 360](https://openjdk.java.net/jeps/360) 提出预览,集成到了 Java 15 中。在 JDK 16 中, 密封类得到了改进(更加严格的引用检查和密封类的继承关系),由 [JEP 397](https://openjdk.java.net/jeps/397) 提出了再次预览。
145145

0 commit comments

Comments
 (0)