近年来即时通信在Internet上得到了越来越广泛的应用,传统服务器所遵循的“拉取”方式并不能很好地满足实际应用中信息获取实时性、用户请求高并发等方面的需求.为了改善上述问题,以“推送”方式进行实时消息传递成为研究热点.通过采用WebSocket技术,以Node.js、Redis、RabbitMQ等开源项目为基础,设计实现一个WebSocket服务器,能够对大量不同用户的订阅请求提供实时消息推送服务,并改进了Node.js多进程管理模块.实验结果表明,单个WebSocket服务器在处理1 000以上的并发连接时,错位率在1.52%左右,有效地实现了WebSocket服务器的高并发与稳定性.%In recent years,instant messaging has been more and more widely used on the Internet.The Pull model adopted in the traditional servers cannot well meet the requirements of real-time information acquisition and high concurrent using accesses in the practical applications.In order to deal with the aforementioned problem,using the Push model in the real-time message transmission has become a research hotspot.Based on open source projects of Node.js,Redis and RabbitMQ,a WebSocket server is designed and implemented.The WebSocket server can provide real-time message push service to a large number of different users' subscription requests.In the WebSocket server,the Node.js multi-process management module is modified.Experimental results show that when a single WebSocket server handles more than 1 000 concurrent connections,the dislocation rate is around 1.52%,which effectively achieves the high concurrency and stability of the WebSocket server.
展开▼