1 / 14

实时消息推送系统

实时消息推送系统. —— 在移动互联网中的设计和实现 吴仲深 @ 阿里云无线. 无线网络速率对比. 参考 : http://en.wikipedia.org/wiki/List_of_device_bandwidths#Mobile_telephone_interfaces. 关键指标. 电量 小于5%* 流量 小于3MB/月* 性能 30秒内发送10w条次消息 稳定性 最高24小时不断线 / 消息100%到达 安全 基于Oauth Token的云帐号体系/ CloudUUID / AES加密. * 24小时均联网. 系统设计.

rupali
Download Presentation

实时消息推送系统

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 实时消息推送系统 ——在移动互联网中的设计和实现 吴仲深 @阿里云无线

  2. 无线网络速率对比 参考: http://en.wikipedia.org/wiki/List_of_device_bandwidths#Mobile_telephone_interfaces

  3. 关键指标 • 电量 小于5%* • 流量 小于3MB/月* • 性能 30秒内发送10w条次消息 • 稳定性 最高24小时不断线 / 消息100%到达 • 安全 基于Oauth Token的云帐号体系/ CloudUUID / AES加密 * 24小时均联网

  4. 系统设计 • 开发语言 • 数据库 • 通讯协议

  5. 服务器架构 Admin后台 API 服务器 BS广播服务器 DB 数据库 WS NCM 导航服务器

  6. 开发中遇到的难题 • 9493端口的由来. • 客户端心跳程序跟随系统一起休眠了. • 从websocket到mqtt,协议的研究 • hashring的算法不一样 • 心跳策略和算法的摸索,gprs/edge,hspa/umts,wifi不同网络制式下的keepalive time。 • 重复发送和收不到,如何防止多个长连接。

  7. 系统调优 • Linux 系统内核 socket connection 调优 • 查看总限制参数 • ulimit -a • 查看 Linux 系统级的最大打开文件数限制: • cat /proc/sys/fs/file-max • *通常这个系统级硬限制是 Linux系统在启动时根据系统硬件资源状况计算出来的最佳的最大同时打开文件数限制。这个也 • 间接告诉我们这台机器可以同时承受 socket 的最大链接数。 • 第一步,修改用户进程可打开文件数限制,修改/etc/security/limits.conf文件,在文件中添加如下行: • * soft nofile 655350 • * hard nofile 655360 • 第二步,修改网络内核对 TCP 连接的有关限制 ,修改/etc/sysctl.conf文件, 在文件中添加如下行: • net.ipv4.ip_conntrack_max = 655350 • *Linux 网络内核的 IP_TABLE 防火墙对最大跟踪的 TCP连接数有限制,此限制值要尽量小,以节省对内核内存的占用。 • 第三步,执行 sysctl 命令 • sysctl -p • 修改客户机的端口范围 • 修改/etc/sysctl.conf文件,在文件中添加如下行: • net.ipv4.ip_local_port_range = 1024 65000 • sysctl -p • 参考 http://blog.csdn.net/guowake/article/details/6615728 • 《http长连接200万尝试及调优 》http://rdc.taobao.com/blog/cs/?p=1062

  8. 调试工具 • Wireshark • tcpdump 命令:tcpdump -s0 -w /sdcard/a.pcap • adb logcat • 电流表

  9. 心跳电量消耗图 WIFI 3G 2G

  10. 性能测试 分析:在整个性能测试过程中,可用内存一直维持在 9G 左右;仅维持 MQTT 连接时 CPU 利用率维持在 40%左右。本测试场景使用 9 台压力测试机,运行 5500(在测试过程中, 1000个虚拟用户失去连接)个虚拟用户,每个虚拟用户建立50个MQTT连接。运行 21 hours, 17 minutes and 58 seconds。 结论:达到了 1 台 WS服务器最高承载 27.5W 个连接并能够正常保持登录的目标。

  11. 日志和性能数据 • Mangodb+ flex

  12. 与第三方应用的关系

  13. 如何使用API • 服务器端开发 • 第一步,通过http get请求访问COA提供的authLogin接口, 获取AcesssToken • 第二步,创建Post请求访问COA提供的pushMesage接口 • 客户端开发 • 云应用客户端开发 • 本地应用客户端开发 • 第一步,创建Manifest文件 • 第二步,接收消息

  14. 谢 谢! 吴仲深 zhongshen.wuzs@aliyun-inc.com

More Related