{"action":"created","issue":{"url":"https://api.github.com/repos/xiangwangfeng/xiangwangfeng.github.io/issues/4","repository_url":"https://api.github.com/repos/xiangwangfeng/xiangwangfeng.github.io","labels_url":"https://api.github.com/repos/xiangwangfeng/xiangwangfeng.github.io/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/xiangwangfeng/xiangwangfeng.github.io/issues/4/comments","events_url":"https://api.github.com/repos/xiangwangfeng/xiangwangfeng.github.io/issues/4/events","html_url":"https://github.com/xiangwangfeng/xiangwangfeng.github.io/issues/4","id":152202286,"number":4,"title":"请教关于移动 IM 开发之登录优化之同步策略优化","user":{"login":"hawk0620","id":5633917,"avatar_url":"https://avatars.githubusercontent.com/u/5633917?v=3","gravatar_id":"","url":"https://api.github.com/users/hawk0620","html_url":"https://github.com/hawk0620","followers_url":"https://api.github.com/users/hawk0620/followers","following_url":"https://api.github.com/users/hawk0620/following{/other_user}","gists_url":"https://api.github.com/users/hawk0620/gists{/gist_id}","starred_url":"https://api.github.com/users/hawk0620/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hawk0620/subscriptions","organizations_url":"https://api.github.com/users/hawk0620/orgs","repos_url":"https://api.github.com/users/hawk0620/repos","events_url":"https://api.github.com/users/hawk0620/events{/privacy}","received_events_url":"https://api.github.com/users/hawk0620/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-01T14:36:49Z","updated_at":"2016-05-05T07:14:41Z","closed_at":null,"body":"你好，首先谢谢你奉献出这么棒的文章；）我在阅读到同步策略优化的时候有点困惑。\r\n显然全同步是无法接受的，改进的方法自然是按时间戳同步。客户端永远只更新比本地缓存数据新的数据。\r\n更新比本地缓存数据新的数据这里不是很理解。客户端没有拿到新的数据前，依据什么与已经缓存的数据对比呢？\r\n希望你能不吝赐教，感谢～"},"comment":{"url":"https://api.github.com/repos/xiangwangfeng/xiangwangfeng.github.io/issues/comments/217091455","html_url":"https://github.com/xiangwangfeng/xiangwangfeng.github.io/issues/4#issuecomment-217091455","issue_url":"https://api.github.com/repos/xiangwangfeng/xiangwangfeng.github.io/issues/4","id":217091455,"user":{"login":"xiangwangfeng","id":5561963,"avatar_url":"https://avatars.githubusercontent.com/u/5561963?v=3","gravatar_id":"","url":"https://api.github.com/users/xiangwangfeng","html_url":"https://github.com/xiangwangfeng","followers_url":"https://api.github.com/users/xiangwangfeng/followers","following_url":"https://api.github.com/users/xiangwangfeng/following{/other_user}","gists_url":"https://api.github.com/users/xiangwangfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/xiangwangfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiangwangfeng/subscriptions","organizations_url":"https://api.github.com/users/xiangwangfeng/orgs","repos_url":"https://api.github.com/users/xiangwangfeng/repos","events_url":"https://api.github.com/users/xiangwangfeng/events{/privacy}","received_events_url":"https://api.github.com/users/xiangwangfeng/received_events","type":"User","site_admin":false},"created_at":"2016-05-05T07:14:41Z","updated_at":"2016-05-05T07:14:41Z","body":"我这边主要是做客户端为主，所以并没有实际的服务器设计经验。只能说说大致的思路\r\n我们管面向具体客户端的服务器为消息服务器，这个服务器维持了当前连接上的客户端状态，举个例子，单机支持10K个客户端，那么必然导致a客户端连接到的是A服务器，b客户端连接到B服务器，而当A客户端收到a发给b的消息时，A就需要找到B服务器，并由B下发这个消息。这个寻找的过程其实并不归A服务器管，中间常常会有Dispatch Server这种概念，A所有的消息都先丢给Dispatch Server，由Dispatch Server找到B，并发送给B，最终由 B服务器投递相应的消息到 b客户端。当然这个Dispatch Server必然不是单机的，而由于他只负责记录客户端连接状态，每个客户端记录的信息都比较少，即使一台机器上记录了 100 W用户量的信息，就算一个客户端在线状态需要 1K 来记录，总共内存占用也不过 1GB而已，而服务器内存往往又超大，所以堆几台机器出来都足够照顾所有的客户端在线状态。"}}