十分钟构建高性能微信后台<br />Twitter:Dcshi<br />Sina:Dcshi<br />2011-03-31<br />
Redis<br />High-performance key-value store<br />- Redis VS Memcache<br />data structure server <br /> - strings, hashes, ...
Redis VS Memcache<br />http://timyang.net/data/mcdb-tt-redis/<br />http://antirez.com/post/redis-memcached-benchmark.html<...
Webdis<br />Providing an HTTP interface to Redis<br />    curl http://127.0.0.1:7379/SET/hello/world<br />   Base on libev...
微信是神马?<br />
Mockup(A)<br />
Mockup(B)<br />
Connection<br />Socket<br />Tcp<br />Udp<br />长连接:<br />     Comet<br />    Pub/Sub<br />轮询<br />Webdis<br />
轮询<br />
Data Structure<br />Friends list:<br />Sorted Sets:<br />      - key : “friends:user_id”<br />      - val:  (‘friend_id1’,...
Operation<br />Send a message:<br />     - Zincrby(http://redis.io/commands/zincrby)<br />        - Me      +0<br />      ...
Operation-mockup(A)<br />初始化页面:<br />    - Nick<br />   - Avata<br />- Latest message(content + time)<br />检查未读消息数<br />  ...
Operation-mockup(B)<br />初始化页面<br />Lrange<br />Zincrby<br />检查未读消息数<br />curl http://localhost:7379/zscore/message:user_i...
Q&A<br />
Upcoming SlideShare
Loading in …5
×

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

6,727 views

Published on

基于redis,一个类Kik应用的后台实现

Published in: Technology
0 Comments
34 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,727
On SlideShare
0
From Embeds
0
Number of Embeds
42
Actions
Shares
0
Downloads
278
Comments
0
Likes
34
Embeds 0
No embeds

No notes for slide

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

  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 />

×