长连接网关技术专题(四):爱奇艺WebSocket实时推送网关技术实践

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本文由爱奇艺技术团队原创分享,原题《构建通用WebSocket推送网关的设计与实践》,有优化和改动。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"1、引言","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"丛所周之,HTTP协议是一种无状态、基于TCP的请求/响应模式的协议,即请求只能由客户端发起、由服务端进行响应。在大多数场景,这种请求/响应的Pull模式可以满足需求。但在某些情形:例如消息推送(IM中最为常见,比如IM的离线消息推送)、实时通知等应用场景,需要实时将数据同步到客户端,这就要求服务端支持主动Push数据的能力。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"传统的Web服务端推送技术历史悠久,经历了短轮询、长轮询等阶段的发展(见《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-338-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"新手入门贴:史上最全Web端即时通讯技术原理详解","attrs":{}}]},{"type":"text","text":"》),一定程度上能够解决问题,但也存在着不足,例如时效性、资源浪费等。HTML5标准带来的WebSocket规范基本结束了这一局面,成为目前服务端消息推送技术的主流方案。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在系统中集成WebSocket十分简单,相关讨论与资料很丰富。但如何实现一个通用的WebSocket推送网关尚未有成熟的方案。目前的云服务厂商主要关注iOS和安卓等移动端推送,也缺少对WebSocket的支持。本文分享了爱奇艺基于Netty实现WebSocket长连接实时推送网关时的实践经验总结。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/0f/0f781672bdab9743e8f16d6a8b7ddcbe.png","alt":"","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"学习交流:","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"- 移动端IM开发入门文章:《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-464-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"新手入门一篇就够:从零开发移动端IM","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"- 开源IM框架源码:","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/JackJiang2011/MobileIMSDK","title":null,"type":null},"content":[{"type":"text","text":"https://github.com/JackJiang2011/MobileIMSDK","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(本文同步发布于:","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3539-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"http://www.52im.net/thread-3539-1-1.html","attrs":{}}]},{"type":"text","text":")","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"2、专题目录","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"本文是系列文章的第4篇,总目录如下:","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1243-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"长连接网关技术专题(一):京东京麦的生产级TCP网关技术实践总结","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-2737-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"长连接网关技术专题(二):知乎千万级并发的高性能长连接网关技术实践","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3110-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"长连接网关技术专题(三):手淘亿级移动端接入层网关的技术演进之路","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3539-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"长连接网关技术专题(四):爱奇艺WebSocket实时推送网关技术实践","attrs":{}}]},{"type":"text","text":"》(* 本文)","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"其它相关技术文章:","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-166-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"绝对干货:基于Netty实现海量接入的推送服务技术要点","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1548-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"京东到家基于Netty的WebSocket应用实践分享","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"爱奇艺技术团队分享的其它文章:","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3028-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"爱奇艺技术分享:轻松诙谐,讲解视频编解码技术的过去、现在和将来","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-2221-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"爱奇艺技术分享:爱奇艺Android客户端启动速度优化实践总结","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-2981-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"爱奇艺移动端网络优化实践分享:网络请求成功率优化篇","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"3、旧方案存在的技术痛点","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"爱奇艺号是我们内容生态的重要组成,作为前台系统,对用户体验有较高要求,直接影响着创作者的创作热情。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"目前,爱奇艺号多个业务场景中用到了WebSocket实时推送技术,包括:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1)用户评论:实时的将评论消息推送到浏览器;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2)实名认证:合同签署前需要对用户进行实名认证,用户扫描二维码后进入第三方的认证页面,认证完成后异步通知浏览器认证的状态;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3)活体识别:类似实名认证,当活体识别完成后,异步将结果通知浏览器。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在实际的业务开发中,我们发现,WebSocket实时推送技术在使用中存在一些问题。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"这些问题是:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1)首先:WebSocket技术栈不统一,既有基于Netty实现的,也有基于Web容器实现的,给开发和维护带来困难;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2)其次:WebSocket实现分散在在各个工程中,与业务系统强耦合,如果有其他业务需要集成WebSocket,面临着重复开发的窘境,浪费成本、效率低下;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3)第三:WebSocket是有状态协议的,客户端连接服务器时只和集群中一个节点连接,数据传输过程中也只与这一节点通信。WebSocket集群需要解决会话共享的问题。如果只采用单节点部署,虽然可以避免这一问题,但无法水平扩展支撑更高负载,有单点的风险;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4)最后:缺乏监控与报警,虽然可以通过Linux的Socket连接数大致评估WebSocket长连接数,但数字并不准确,也无法得知用户数等具有业务含义的指标数据;无法与现有的微服务监控整合,实现统一监控和报警。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"PS:","attrs":{}},{"type":"text","text":"限于篇幅本文不详细介绍WebSocket技术本身,有兴趣可以详读《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3134-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"WebSocket从入门到精通,半小时就够!","attrs":{}}]},{"type":"text","text":"》。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"4、新方案的技术目标","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如上节所示,为了解决旧方案中存在的问题,我们需要实现统一的WebSocket长连接实时推送网关。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"这套新的网关需要具备如下特点:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1)集中实现长连接管理和推送能力:统一技术栈,将长连接作为基础能力沉淀,便于功能迭代和升级维护;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2)与业务解耦:将业务逻辑与长连接通信分离,使业务系统不再关心通信细节,也避免了重复开发,浪费研发成本;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3)使用简单:提供HTTP推送通道,方便各种开发语言的接入。业务系统只需要简单的调用,就可以实现数据推送,提升研发效率;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4)分布式架构:实现多节点的集群,支持水平扩展应对业务增长带来的挑战;节点宕机不影响服务整体可用性,保证高可靠;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"5)多端消息同步:允许用户使用多个浏览器或标签页同时登陆在线,保证消息同步发送;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"6)多维度监控与报警:自定义监控指标与现有微服务监控系统打通,出现问题时可及时报警,保证服务的稳定性。","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"5、新方案的技术选型","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在众多的WebSocket实现中,从性能、扩展性、社区支持等方面考虑,最终选择了Netty。Netty是一个高性能、事件驱动、异步非阻塞的网络通信框架,在许多知名的开源软件中被广泛使用。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"PS:","attrs":{}},{"type":"text","text":"如果你对Netty知之甚少,可以详读以下两篇:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3207-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"史上最通俗Netty入门长文:基本介绍、环境搭建、动手实战","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-2043-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"新手入门:目前为止最透彻的的Netty高性能原理和框架架构解析","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"WebSocket是有状态的,无法像直接HTTP以集群方式实现负载均衡,长连接建立后即与服务端某个节点保持着会话,因此集群下想要得知会话属于哪个节点有点困难。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"解决以上问题一般有两种技术方案:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1)一种是使用类似微服务的注册中心来维护全局的会话映射关系;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2)一种是使用事件广播由各节点自行判断是否持有会话,两种方案对比如下表所示。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"WebSocket集群方案:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/85/850f4ebd90b1d10b17187318d1e88b6b.png","alt":"","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"综合考虑实现成本与集群规模,选择了轻量级的事件广播方案。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"实现广播可以选择基于RocketMQ的消息广播、基于Redis的Publish/Subscribe、基于ZooKeeper的通知等方案,其优缺点对比如下表所示。从吞吐量、实时性、持久化、实现难易等方面考虑,最终选择了RocketMQ。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"广播的实现方案对比:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/e9/e95e9fe4fabd86a18f851771029f39fb.jpeg","alt":"","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"6、新方案的实现思路","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"6.1 系统架构","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"网关的整体架构如下图所示:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/3a/3ae291f20352ddafae58f57cada45ff5.jpeg","alt":"","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"网关的整体流程如下:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"1)","attrs":{}},{"type":"text","text":"客户端与网关任一节点握手建立起长连接,节点将其加入到内存维护的长连接队列。客户端定时向服务端发送心跳消息,如果超过设定的时间仍没有收到心跳,则认为客户端与服务端的长连接已断开,服务端会关闭连接,清理内存中的会话。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"2)","attrs":{}},{"type":"text","text":"当业务系统需要向客户端推送数据时,通过网关提供的HTTP接口将数据发向网关。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"3)","attrs":{}},{"type":"text","text":"网关在接收到推送请求后,将消息写入RocketMQ。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"4)","attrs":{}},{"type":"text","text":"网关作为消费者,以广播模式消费消息,所有节点都会接收到消息。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"5)","attrs":{}},{"type":"text","text":"节点接收到消息后判断推送的消息目标是否在自己内存中维护的长连接队列里,如果存在则通过长连接推送数据,否则直接忽略。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"网关以多节点方式构成集群,每节点负责一部分长连接,可实现负载均衡,当面对海量连接时,也可以通过增加节点的方式分担压力,实现水平扩展。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"同时,当节点出现宕机时,客户端会尝试重新与其他节点握手建立长连接,保证服务整体的可用性。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"6.2 会话管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"WebSocket长连接建立起来后,会话维护在各节点的内存中。SessionManager组件负责管理会话,内部使用了哈希表维护了UID与UserSession的关系。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"UserSession代表用户维度的会话,一个用户可能会同时建立多个长连接,因此UserSession内部同样使用了一个哈希表维护","attrs":{}},{"type":"link","attrs":{"href":"http://docs.52im.net/extend/docs/src/netty4_1/io/netty/channel/Channel.html","title":null,"type":null},"content":[{"type":"text","text":"Channel","attrs":{}}]},{"type":"text","text":"与ChannelSession的关系。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"为了避免用户无限制的创建长连接,UserSession在内部的ChannelSession超过一定数量后,会将最早建立的ChannelSession关闭,减少服务器资源占用。SessionManager、UserSession、ChannelSession的关系如下图所示。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"SessionManager组件:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/6f/6f138edbc7e35a468270b8955f4ab1f7.jpeg","alt":"","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"6.3 监控与报警","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"为了了解集群建立了多少长连接、包含了多少用户,网关提供了基本的监控与报警能力。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"网关接入了","attrs":{}},{"type":"link","attrs":{"href":"https://links.jianshu.com/go?to=https%3A//www.oschina.net/p/micrometer%3Fhmsr%3Daladdin1e1","title":null,"type":null},"content":[{"type":"text","text":"Micrometer","attrs":{}}]},{"type":"text","text":",将连接数与用户数作为自定义指标暴露,供","attrs":{}},{"type":"link","attrs":{"href":"https://links.jianshu.com/go?to=https%3A//prometheus.io/","title":null,"type":null},"content":[{"type":"text","text":"Prometheus","attrs":{}}]},{"type":"text","text":"进行采集,实现了与现有的微服务监控系统打通。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在","attrs":{}},{"type":"link","attrs":{"href":"https://links.jianshu.com/go?to=https%3A//grafana.com/","title":null,"type":null},"content":[{"type":"text","text":"Grafana","attrs":{}}]},{"type":"text","text":"中方便地查看连接数、用户数、JVM、CPU、内存等指标数据,了解网关当前的服务能力与压力。报警规则也可以在Grafana中配置,当数据异常时触发奇信(内部报警平台)报警。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"7、新方案的性能压测","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"压测准备:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1)压测选择两台配置为4核16G的虚拟机,分别作为服务器和客户端;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2)压测时选择为网关开放了20个端口,同时建立20个客户端;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3)每个客户端使用一个服务端端口建立起5万连接,可以同时创建百万个连接。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"连接数(百万级)与内存使用情况如下图所示:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/32/328fb581ef9bf1c25b1193bd7af7e028.png","alt":"","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"给百万个长连接同时发送一条消息,采用单线程发送,服务器发送完成的平均耗时在10s左右,如下图所示。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"服务器推送耗时:","attrs":{}},{"type":"text","text":" ","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/3c/3c5682b017db4040754f6aaa4c0382f8.png","alt":"","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一般同一用户同时建立的长连接都在个位数。以10个长连接为例,在并发数600、持续时间120s条件下压测,推送接口的TPS大约在1600+,如下图所示。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"长连接10、并发600、持续时间120s的压测数据:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/bf/bf589ddf34946f94858cd5b08a52c0bf.png","alt":"","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"当前的性能指标已满足我们的实际业务场景,可支持未来的业务增长。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"8、新方案的实际应用案例","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"为了更生动的说明优化效果,文章最后,我们也以封面图添加滤镜效果为例,介绍一个爱奇艺号使用新WebSocket网关方案的案例。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"爱奇艺号自媒体发表视频时,可选择为封面图添加滤镜效果,引导用户提供提供更优质的封面。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"当用户选择一个封面图后,会提交异步的后台处理任务。当异步任务处理完成后,通过WebSocket将不同滤镜效果处理后的图片返回给浏览器,业务场景如下图所示。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/de/dec2f89ff1fa1a1e7111d950fbf46273.png","alt":"","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"从研发效率方面考虑,如果在业务系统中集成WebSocket,至少需要1-2天的开发时间。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果直接使用新的WebSocket网关的推送能力,只需要简单的接口调用就实现了数据推送,开发时间降低到分钟级别,研发效率大大提高。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"从运维成本方面考虑,业务系统不再含有与业务逻辑无关的通信细节,代码的可维护性更强,系统架构变得更加简单,运维成本大大降低。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"9、写在最后","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"WebSocket是目前实现服务端推送的主流技术,恰当使用能够有效提供系统响应能力,提升用户体验。通过WebSocket长连接网关可以快速为系统增加数据推送能力,有效减少运维成本,提高开发效率。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"长连接网关的价值在于:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1)它封装了WebSocket通信细节,与业务系统解耦,使得长连接网关与业务系统可独立优化迭代,避免重复开发,便于开发与维护;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2)网关提供了简单易用的HTTP推送通道,支持多种开发语言接入,便于系统集成和使用;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3)网关采用了分布式架构,可以实现服务的水平扩容、负载均衡与高可用;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4)网关集成了监控与报警,当系统异常时能及时预警,保证服务的健康和稳定。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"目前,新的WebSocket长连接实时网关已在爱奇艺号图片滤镜结果通知、MCN电子签章等多个业务场景中得到应用。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"未来还有许多方面需要探索,例如消息的重发与ACK、WebSocket二进制数据的支持、多租户的支持等。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"附录:更多相关技术资料","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"[1] 有关WEB端即时通讯开发:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-338-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"新手入门贴:史上最全Web端即时通讯技术原理详解","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-336-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"Web端即时通讯技术盘点:短轮询、Comet、Websocket、SSE","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-335-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"SSE技术详解:一种全新的HTML5服务器推送事件技术","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-334-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"Comet技术详解:基于HTTP长连接的Web端实时通信技术","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-831-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"新手快速入门:WebSocket简明教程","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-331-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"WebSocket详解(一):初步认识WebSocket技术","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-326-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"WebSocket详解(二):技术原理、代码演示和应用案例","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-332-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"WebSocket详解(三):深入WebSocket通信协议细节","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1258-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"WebSocket详解(四):刨根问底HTTP与WebSocket的关系(上篇)","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1266-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"WebSocket详解(五):刨根问底HTTP与WebSocket的关系(下篇)","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1273-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"WebSocket详解(六):刨根问底WebSocket与Socket的关系","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-188-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"socket.io实现消息推送的一点实践及思路","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-659-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"LinkedIn的Web端即时通讯实践:实现单机几十万条长连接","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-690-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"Web端即时通讯技术的发展与WebSocket、Socket.io的技术实践","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-793-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"Web端即时通讯安全:跨站点WebSocket劫持漏洞详解(含示例代码)","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-849-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"开源框架Pomelo实践:搭建Web端高性能分布式IM聊天服务器","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-907-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"使用WebSocket和SSE技术实现Web端消息推送","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1038-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"详解Web端通信方式的演进:从Ajax、JSONP 到 SSE、Websocket","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1248-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"MobileIMSDK-Web的网络层框架为何使用的是Socket.io而不是Netty?","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1341-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"理论联系实际:从零理解WebSocket的通信原理、协议格式、安全性","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1703-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"微信小程序中如何使用WebSocket实现长连接(含完整源码)","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-2488-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"八问WebSocket协议:为你快速解答WebSocket热门疑问","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3098-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"Web端即时通讯实践干货:如何让你的WebSocket断网重连更快速?","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3134-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"WebSocket从入门到精通,半小时就够!","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3175-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"WebSocket硬核入门:200行代码,教你徒手撸一个WebSocket服务器","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":">> ","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/forum.php%3Fmod%3Dcollection%26action%3Dview%26ctid%3D15","title":null,"type":null},"content":[{"type":"text","text":"更多同类文章 ……","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"[2] 有关推送技术的文章:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-315-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"一个基于MQTT通信协议的完整Android推送Demo","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-314-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"求教android消息推送:GCM、XMPP、MQTT三种方案的优劣","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-288-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"移动端实时消息推送技术浅析","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-166-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"绝对干货:基于Netty实现海量接入的推送服务技术要点","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-602-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"极光推送系统大规模高并发架构的技术实践分享","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-723-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"魅族2500万长连接的实时消息推送架构的技术实践分享","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-750-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"专访魅族架构师:海量长连接的实时消息推送系统的心得体会","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-773-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"基于WebSocket实现Hybrid移动应用的消息推送实践(含代码示例)","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-776-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"一个基于长连接的安全可扩展的订阅/推送服务实现思路","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-800-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"实践分享:如何构建一套高可用的移动端消息推送系统?","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-848-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"Go语言构建千万级在线的高并发消息推送系统实践(来自360公司)","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-999-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"腾讯信鸽技术分享:百亿级实时消息推送的实战经验","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1236-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"百万在线的美拍直播弹幕系统的实时推送技术实践之路","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-1321-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"京东京麦商家开放平台的消息推送架构演进之路","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-2096-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"技术干货:从零开始,教你设计一个百万级的消息推送系统","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3539-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"长连接网关技术专题(四):爱奇艺WebSocket实时推送网关技术实践","attrs":{}}]},{"type":"text","text":"》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":">> ","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/forum.php%3Fmod%3Dcollection%26action%3Dview%26ctid%3D11","title":null,"type":null},"content":[{"type":"text","text":"更多同类文章 ……","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"本文已同步发布于“即时通讯技术圈”公众号。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"▲ 本文在公众号上的链接是:","attrs":{}},{"type":"link","attrs":{"href":"https://mp.weixin.qq.com/s/5ZUn41iVnJi3_kQ1wW5v6w","title":null,"type":null},"content":[{"type":"text","text":"点此进入","attrs":{}}]},{"type":"text","text":"。同步发布链接是:","attrs":{}},{"type":"link","attrs":{"href":"http://www.52im.net/thread-3539-1-1.html","title":null,"type":null},"content":[{"type":"text","text":"http://www.52im.net/thread-3539-1-1.html","attrs":{}}]}]}],"attrs":{}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章