6

心跳 heartBeat 的不同场景下实现疑问

 2 years ago
source link: https://www.v2ex.com/t/866917
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

心跳 heartBeat 的不同场景下实现疑问

  frank1256 · 1 小时 59 分钟前 · 407 次点击

我理解心跳就是像是微信是否在线的概念。集群中判断节点是否可用就得有 heartBeat 的检测机制。

之前看过一些开源的代码。看到有两种方式。一种是通过 api 接口,由客户端不断的发送 http 请求。服务端来判断是否在线。回调通知的时候通过 /callBack 接口

还有一种是通过长链接。tcp 建立链接后,keepalive ,在同一个链接上发送和接收消息。好像用在实时推送消息更多?

第二种需要缓存当前的链接,意味着更大的缓存,更多的资源消耗吗?达到更快的推送速度?

有大佬指点指点吗,对心跳这块不是很了解


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK