知识卡片

问题卡 · 4470

轮询长轮询与双向连接

理解等级:中级

轮询周期询问是否有消息,空请求多;长轮询等新消息或超时后再发起,减少无效频率;WebSocket 建立持久双向通道,适合实时聊天。持久连接也带来连接归属和失效重连管理。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 聊天 · 查看原书依据

      Polling As shown in Figure 12-3, polling is a technique that the client periodically asks the server if there are messages available. Depending on polling frequency, polling could be costly. It could consume precious server resources to answer a question that offers no as an answer most of the time. Long polling Because polling could be inefficient, the next progression is long polling (Figure 12-4).

    参考来源

    - 位置:《System Design Interview – An insiders guide, Second Edition》第12章《聊天》(来源项目 book-sources;源文件:extracted/System Design Interview – An insiders guide, Second Edition/_epub-src/text/part0029_split_002.html) - 结论依据:原文在该位置给出所述对象、机制或比较,支持本卡的解释;原书未展开的实现不作为已证明结论,算式与一致性边界在正文明确限定。 - 原始内容:Polling As shown in Figure 12-3, polling is a technique that the client periodically asks the server if there are messages available. Depending on polling frequency, polling could be costly. It could consume precious server resources to answer a question that offers no as an answer most of the time. Long polling Because polling could be inefficient, the next progression is long polling (Figure 12-4).