You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "lexburner (GitHub)" <gi...@apache.org> on 2019/01/16 03:06:10 UTC

[GitHub] [incubator-dubbo-website] lexburner opened pull request #247: [Blog] Dubbo 心跳设计


[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
这里应该是个单词拼写问题,不知是否是落掉了

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
```suggestion
私下请教过**美团点评的长连接负责人:俞超(闪电侠)**,美点使用的心跳方案和 Dubbo 改进方案几乎一致,可以说该方案是标准实现了。
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
```suggestion
前面已经介绍过,**Dubbo 采取的是双向心跳设计**,即服务端会向客户端发送心跳,客户端也会向服务端发送心跳,接收的一方更新 lastRead 字段,发送的一方更新 lastWrite 字段,超过心跳间隙的时间,便发送心跳请求给对端。这里的 lastRead/lastWrite 同样会被同一个通道上的普通调用更新,通过更新这两个字段,实现了只在连接空闲时才会真正发送空闲报文的机制,符合我们一开始科普的做法。
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
```suggestion
<2> **创建了一个 `HashedWheelTimer ` 开启心跳检测**,这是 Netty 所提供的一个经典的时间轮定时器实现,至于它和 jdk 的实现有何不同,不了解的同学也可以关注下,我就拓展了。
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
```suggestion
其中 `calculateLeastDuration` 根据心跳时间和超时时间分别计算出了一个 tick 时间,实际上就是将两个变量除以了 3,使得他们的值缩小,并传入了 `HashedWeelTimer` 的第二个参数之中
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] ralf0131 commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
+1 for the last part. I am thinking of dropping the support of mina in Dubbo 3.0 

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
```suggestion
|     **主体设计**     |                        开启两个定时器                        |       借助 IdleStateHandler,底层使用 schedule        |
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] ralf0131 commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
我就不拓展了。

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lexburner commented on issue #247: [Blog] Dubbo 心跳设计

Posted by "lexburner (GitHub)" <gi...@apache.org>.
fixed

> 在 2019年1月24日,下午6:51,XiaoJie Li <no...@github.com> 写道:
> 
> @lixiaojiee commented on this pull request.
> 
> In blog/zh-cn/dubbo-heartbeat-design.md <https://github.com/apache/incubator-dubbo-website/pull/247#discussion_r250554685>:
> 
> > +Dubbo 中默认的心跳周期是 60s,设想如下的时序:
> +
> +- 第 0 秒,心跳检测发现连接活跃
> +- 第 1 秒,连接实际断开
> +- 第 60 秒,心跳检测发现连接不活跃
> +
> +由于**时间窗口的问题,死链不能够被及时检测出来,最坏情况为一个心跳周期**。
> +
> +为了解决上述问题,我们再倒回去看一下上面的 `startHeartbeatTimer()` 方法
> +
> +```java
> +long heartbeatTick = calculateLeastDuration(heartbeat); 
> +long heartbeatTimeoutTick = calculateLeastDuration(heartbeatTimeout);
> +```
> +
> +其中 `calculateLeastDuration` 根据心跳时间和超时时间分别计算出了一个 tick 时间,实际上就是将两个变量除以了 3,使得他们的值缩小,并传入了 `HashWeelTimer` 的第二个参数之中
> 这里应该是个单词拼写问题,不知是否是落掉了
> 
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub <https://github.com/apache/incubator-dubbo-website/pull/247#discussion_r250554685>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AK9DJman9DBKNQEokuNS4AXcQJior7QGks5vGZApgaJpZM4aCOUg>.
> 



[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lexburner commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lexburner (GitHub)" <gi...@apache.org>.
```suggestion
<2> **创建了一个 `HashedWheelTimer ` 开启心跳检测**,这是 Netty 所提供的一个经典的时间轮定时器实现,至于它和 jdk 的实现有何不同,不了解的同学也可以关注下,我就不拓展了。
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
```suggestion
> Dubbo 在早期版本版本中使用的是 schedule 方案,在 2.7.x 中替换成了 HashedWheelTimer。
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] ralf0131 closed pull request #247: [Blog] Dubbo 心跳设计

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
[ pull request closed by ralf0131 ]

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
```suggestion
介绍完了一些基础的概念,我们再来看看 Dubbo 是如何设计应用层心跳的。Dubbo 的心跳是双向心跳,客户端会给服务端发送心跳,反之,服务端也会向客户端发送心跳。
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
这里看上去不太通顺,您是落掉这里了嘛?

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lexburner commented on issue #247: [Blog] Dubbo 心跳设计

Posted by "lexburner (GitHub)" <gi...@apache.org>.
@lixiaojiee Thanks a lot!

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
```suggestion
            desc: 'URL 是 Dubbo 中的一个重要的领域模型,了解它可以更加轻松的理解 Dubbo 的设计理念。',
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lixiaojiee commented on pull request #247: [Blog] Dubbo 心跳设计

Posted by "lixiaojiee (GitHub)" <gi...@apache.org>.
```suggestion
高性能的 RPC 框架几乎都会选择使用 Netty 来作为通信层的组件,非阻塞式通信的高效不需要我做过多的介绍。但也由于非阻塞的特性,导致其发送数据和接收数据是一个异步的过程,所以当存在服务端异常、网络问题时,客户端是接收不到响应的,那么我们如何判断一次 RPC 调用是失败的呢?
```

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo-website] lexburner commented on issue #247: [Blog] Dubbo 心跳设计

Posted by "lexburner (GitHub)" <gi...@apache.org>.
@ralf0131 fixed

[ Full content available at: https://github.com/apache/incubator-dubbo-website/pull/247 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org