Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

More Related Content

You Might Also Like

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

十分钟构建高性能微信后台

  1. 1. 十分钟构建高性能微信后台<br />Twitter:Dcshi<br />Sina:Dcshi<br />2011-03-31<br />
  2. 2. Redis<br />High-performance key-value store<br />- Redis VS Memcache<br />data structure server <br /> - strings, hashes, lists, sets and sorted sets<br />Persistence<br />-Snapshotting, Append-only file<br />http://redis.io<br />
  3. 3. Redis VS Memcache<br />http://timyang.net/data/mcdb-tt-redis/<br />http://antirez.com/post/redis-memcached-benchmark.html<br />
  4. 4. Webdis<br />Providing an HTTP interface to Redis<br /> curl http://127.0.0.1:7379/SET/hello/world<br /> Base on libevent/libev<br />High-performance<br />50,000 http requests per second on a desktop<br />Flexible<br />Json/jsonp….<br />ACL(Access control)<br />
  5. 5. 微信是神马?<br />
  6. 6. Mockup(A)<br />
  7. 7. Mockup(B)<br />
  8. 8. Connection<br />Socket<br />Tcp<br />Udp<br />长连接:<br /> Comet<br /> Pub/Sub<br />轮询<br />Webdis<br />
  9. 9. 轮询<br />
  10. 10. Data Structure<br />Friends list:<br />Sorted Sets:<br /> - key : “friends:user_id”<br /> - val: (‘friend_id1’, friend_id2’,’ friend_id3’,…….)<br />Messages:<br />Lists:<br /> - key : “message:from_id:to_id”<br /> - value:[“time|url|content”, ”time|url|content”,..]<br />
  11. 11. Operation<br />Send a message:<br /> - Zincrby(http://redis.io/commands/zincrby)<br /> - Me +0<br /> - friend +1<br /> - Lpush(http://redis.io/commands/lpush)<br />
  12. 12. Operation-mockup(A)<br />初始化页面:<br /> - Nick<br /> - Avata<br />- Latest message(content + time)<br />检查未读消息数<br /> curl http://localhost:7379/zrevrangebyscore/friends:user_id/+inf/1/withscores<br /> return{"zrevrangebyscore":[“62716","4",“71313","2"]}<br />
  13. 13. Operation-mockup(B)<br />初始化页面<br />Lrange<br />Zincrby<br />检查未读消息数<br />curl http://localhost:7379/zscore/message:user_id/friend_id<br />Return {“zscore”:4}<br />
  14. 14. Q&A<br />

×