Skip to content

Commit

Permalink
✏分布式
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcaffebabe committed Jul 29, 2024
1 parent b36d276 commit 7ec3839
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Binary file removed doc/assets/屏幕截图 2021-11-30 210829.png
Binary file not shown.
13 changes: 12 additions & 1 deletion doc/编程语言/并发模型.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,18 @@ stateDiagram-v2

## Actor

![Actor模型](/assets/屏幕截图%202021-11-30%20210829.png)
```mermaid
graph TD
subgraph Thread
subgraph Actor
数据["数据"]
行为["行为"]
end
mailbox["mailbox"]
Actor --> mailbox
end
```

- 保留了可变状态 只是不共享(每个Actor只存在于属于自己的线程内)
- 单条不可变消息传输(使用mailbox)
Expand Down
17 changes: 17 additions & 0 deletions doc/软件工程/微服务/服务治理/服务容错.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ tags: ['服务架构', '微服务', '服务治理']
并行调用| 尽可能在最短时间内获得最高的成功率| 额外消耗机器资源,大部分调用可能都是无用功| 资源充足且对失败容忍度低的场景
广播调用| 支持同时对批量的服务提供者发起调用| 资源消耗大,失败概率高| 只适用于批量操作的场景

### 心跳机制

基于历史心跳消息预测故障的策略,也就是常说的 φ 值故障检测,φ 值的计算方法

1. 采样窗口存储心跳到达的时间:一个具有固定容量的容器,一般存储近 k 次的心跳信息,每次心跳到达时,会将到达时间存储到采样窗口,通过这些采样数据,可以计算出样本的平均值μ和方差 $σ^2$,以便后面计算 φ 值
2. 通过样本计算出心跳到达时间间隔的分布 , t 个时间片能收到下一次心跳的概率:

$
P_{later}(t)=\frac{1}{\sigma\sqrt{2\pi}}\int_{t}^{+\infty}e^{-\frac{(x-u)^2}{2\sigma^2}}dx=1-F(t)
$

3. 使用得到的正态分布计算当前的 φ 值

$
\varphi(t_{now})\xrightarrow{def}-log_{10}(P_{later}(t_{now}-T_{last}))
$

## 容错设计模式

### 断路器模式
Expand Down

0 comments on commit 7ec3839

Please sign in to comment.