Redis
       @
http://weibo.com/tangfl
     http://fulin.org
• Redis
•         Redis

  •
  •
•
Redis

• in memory (database?)
• data can dump to disk
• many useful data structure
• FAST both read and write
• we start use from 2.0, now 2.4
=feed+   +
=feed+   +


• feed
 •
 •
=feed+   +
=feed+   +


•
    •
    •
=feed+   +
=feed+   +

•
    •
    •       @

    •            @

    •
=feed+   +
=feed+   +

•
    •
    •       @

    •            @

    •
=feed+   +
=feed+   +

•
    •
    •       @

    •            @

    •
=feed+   +
=feed+   +

•
    •
    •       @

    •            @

    •
=feed+   +
=feed+   +

•feed
 • mysql
 • mc
=feed+   +


•
=feed+                                   +
• mysql: relation.following
    •   fromuid, touid, addtime


•   addtime desc
                          select * from following where fromuid=? order by



•   addtime desc
                          select * from following where touid=? order by



•                fromuid, touid
=feed+                                   +
• mysql: relation.following relation.follower
    •   fromuid, touid, addtime


•   addtime desc
                          select * from following where fromuid=? order by



•   desc
                          select * from follower where touid=? order by addtime



•
=feed+   +

•
    •
        •
    •
        •
=feed+        +

•   ta

•                  ta

•             ta

•
=feed+     +

•
    •     c/java

    •
    •
    •
=feed+          +

• redis
• hash :
 • key : user id
 • fields : friends ids
 • value : add time
=feed+                            +
• redis
• hash :
 • hset fromuid.following touid addtime
 • hset touid.follower fromuid addtime
 • hgetAll fromuid. following
 • hgetAll touid.follower ?
   •        11,704,598 @Wed Sep 7 21:46:33 CST 2011
=feed+             +

• hash-max-zip-size
 •   64 -> 256   1/3

 •   cpu


• hgetAll cost too much cpu
 • add mc
• high delay
=feed+   +
=feed+                        +
• redis
 • cache ? waste too much mem
 • storage ?
   • rdb may lost data
   • aof r/w too slow, recover too slow
   • all data in mem, waste money
 •  HA : master slave ? NO WAY
 • memory fragment
=feed+   +
=feed+                  +

•
    • mysql binlog >> queue >> Java Processor
      >> redis
    • mysql binlog >> trigger >> redis
=feed+             +

•
    • redis@weibo for now:
    • TB
    • growing fast
=feed+                  +

•
    •@               mysql modified + innodb

    • following list of a user in one column
    • still under dev
=feed+   +



•
=feed+   +
•
    •
        •
        •@
    •
        •
=feed+   +
=feed+    +
•
    •
        •         @

    •
        •
        •    js
=feed+           +

• mc + queue + mysql
•         mysql

• mc mysql
•                  mc
=feed+   +

•
    •
    •
    •
    •
=feed+             +

• redis
 • k-v , 100 byte per k-v
   •   mc

   •
 • hash , hget pipeline slow
=feed+                +

• redis
 • rdb ? may lost data
 • aof ? grow too fast (4G/day)
 • bgsave/bgrewriteaof influence parent
=feed+   +
=feed+         +

• redis rolling
  •
  •
  •
  •               key
=feed+                 +
•
    • rediscounter @
    • array , not linked list
    • malloc all mem when start
    • hash key to position
    • write disk: asyn & slow down
    • add position to aof file
=feed+                   +

•
    • rediscounter + innodb
    • auto roll cold data to disk
=feed+                                     +

•
    •   @TimYang

    •   @XiaoJunHong

    •
    •   redis (delay) - mc (throughput) - java hash map
•
    • cache
    • storage
•
    •
    •
    •   +

    •
•
    •
    •   /

    •
    •
•
    •
    • rdb or aof
•
    •
    • rehash
• HA / Cluster
 •       Redis

 • Jedis
• CPU
 • Redis
 • hset with big hash-max-zip-size
 • hgetAll
 •         mc
•
    •
    •
    •
    •
Thanks

       @
http://weibo.com/tangfl
     http://fulin.org
Q &A
   PS. We are hiring !
contact me via @

More Related Content

PDF
新浪微博开放平台Redis实战
PDF
Timyang新浪微博设计谈
KEY
微博cache设计谈
PPTX
Redis and it's data types
PPTX
A simple introduction to redis
PDF
Cassandra vs. Redis
PPTX
PDF
Amebaサービスのログ解析基盤
新浪微博开放平台Redis实战
Timyang新浪微博设计谈
微博cache设计谈
Redis and it's data types
A simple introduction to redis
Cassandra vs. Redis
Amebaサービスのログ解析基盤

What's hot (20)

PPTX
Redis/Lessons learned
PDF
Realtime Search Infrastructure at Craigslist (OpenWest 2014)
PDF
企業・業界情報プラットフォームSPEEDAにおけるElasticsearchの活用
PPTX
Redis 101 Data Structure
PDF
Redis and its many use cases
PDF
Data Intelligence 2017 - Building a Gigaword Corpus
PPTX
Hortonworks HBase Meetup Presentation
PPTX
Introduction to Redis
PDF
Building a Gigaword Corpus (PyCon 2017)
PDF
MongoDB使用技巧
PPTX
Efficient cluster resource management by using Cook and Mesos / Li Jin (Two S...
PDF
NOVA Data Science Meetup 5/10/2017 - Presentation Building a gigaword corpus
PDF
Environment for training models
PPTX
Redis Introduction
PDF
Apache CouchDB talk at Ontario GNU Linux Fest
KEY
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
PDF
Introduction to Mongodb
KEY
Sphinx at Craigslist in 2012
PDF
Redis for .NET Developers
PPTX
Hops - Distributed metadata for Hadoop
Redis/Lessons learned
Realtime Search Infrastructure at Craigslist (OpenWest 2014)
企業・業界情報プラットフォームSPEEDAにおけるElasticsearchの活用
Redis 101 Data Structure
Redis and its many use cases
Data Intelligence 2017 - Building a Gigaword Corpus
Hortonworks HBase Meetup Presentation
Introduction to Redis
Building a Gigaword Corpus (PyCon 2017)
MongoDB使用技巧
Efficient cluster resource management by using Cook and Mesos / Li Jin (Two S...
NOVA Data Science Meetup 5/10/2017 - Presentation Building a gigaword corpus
Environment for training models
Redis Introduction
Apache CouchDB talk at Ontario GNU Linux Fest
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
Introduction to Mongodb
Sphinx at Craigslist in 2012
Redis for .NET Developers
Hops - Distributed metadata for Hadoop
Ad

Similar to 新浪微博开放平台中的 Redis 实践 (20)

PDF
Developing polyglot persistence applications (SpringOne India 2012)
PDF
Developing polyglot persistence applications (SpringOne China 2012)
PDF
Developing polyglot persistence applications #javaone 2012
KEY
High Performance Weibo QCon Beijing 2011
PDF
超カジュアルに使うMySQL @ MySQL Casual Talks #2
PDF
Using Spring with NoSQL databases (SpringOne China 2012)
PDF
Developing polyglot persistence applications (devnexus 2013)
KEY
KeyValue Stores
PDF
Redis 坑
PDF
To SQL or No(t)SQL - PFCongres 2012
KEY
Nosql redis-mongo
PDF
NoSQL Overview
PDF
SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012
PDF
Mongodb my
PDF
MongoDB
PDF
NoSql Databases and Polyglot Applications
PDF
Redis memcached pdf
PDF
PDF
WebCamp: Developer Day: The Big, the Small and the Redis - Андрей Савченко
Developing polyglot persistence applications (SpringOne India 2012)
Developing polyglot persistence applications (SpringOne China 2012)
Developing polyglot persistence applications #javaone 2012
High Performance Weibo QCon Beijing 2011
超カジュアルに使うMySQL @ MySQL Casual Talks #2
Using Spring with NoSQL databases (SpringOne China 2012)
Developing polyglot persistence applications (devnexus 2013)
KeyValue Stores
Redis 坑
To SQL or No(t)SQL - PFCongres 2012
Nosql redis-mongo
NoSQL Overview
SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012
Mongodb my
MongoDB
NoSql Databases and Polyglot Applications
Redis memcached pdf
WebCamp: Developer Day: The Big, the Small and the Redis - Андрей Савченко
Ad

More from fulin tang (14)

PDF
雪球大数据体系实践
PDF
雪球服务化实践历程.Print
PPTX
订阅互联网
PPTX
我的奋斗 @ weibo
PDF
一个Nosql的故事
PDF
Redis大数据之路 dtcc-唐福林
PDF
Gizzard, DAL and more
PDF
音乐搜索的极致
PDF
基于Lucene的站内搜索 Beta
ODP
基于 lucene 的站内搜索
PPT
Voldemort Intro Tangfl
PPT
基于Lucene的站内搜索
ODP
基于Lucene的站内搜索
PDF
毕业设计-Slide
雪球大数据体系实践
雪球服务化实践历程.Print
订阅互联网
我的奋斗 @ weibo
一个Nosql的故事
Redis大数据之路 dtcc-唐福林
Gizzard, DAL and more
音乐搜索的极致
基于Lucene的站内搜索 Beta
基于 lucene 的站内搜索
Voldemort Intro Tangfl
基于Lucene的站内搜索
基于Lucene的站内搜索
毕业设计-Slide

Recently uploaded (20)

PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
UiPath Agentic Automation session 1: RPA to Agents
PPTX
Configure Apache Mutual Authentication
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
Modernising the Digital Integration Hub
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
Build Your First AI Agent with UiPath.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PPT
Geologic Time for studying geology for geologist
PDF
Architecture types and enterprise applications.pdf
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Zenith AI: Advanced Artificial Intelligence
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Developing a website for English-speaking practice to English as a foreign la...
UiPath Agentic Automation session 1: RPA to Agents
Configure Apache Mutual Authentication
OpenACC and Open Hackathons Monthly Highlights July 2025
Module 1.ppt Iot fundamentals and Architecture
Modernising the Digital Integration Hub
A proposed approach for plagiarism detection in Myanmar Unicode text
Build Your First AI Agent with UiPath.pptx
Chapter 5: Probability Theory and Statistics
Custom Battery Pack Design Considerations for Performance and Safety
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Geologic Time for studying geology for geologist
Architecture types and enterprise applications.pdf
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
1 - Historical Antecedents, Social Consideration.pdf
Enhancing plagiarism detection using data pre-processing and machine learning...

新浪微博开放平台中的 Redis 实践

  • 1. Redis @ http://weibo.com/tangfl http://fulin.org
  • 2. • Redis • Redis • • •
  • 3. Redis • in memory (database?) • data can dump to disk • many useful data structure • FAST both read and write • we start use from 2.0, now 2.4
  • 4. =feed+ +
  • 5. =feed+ + • feed • •
  • 6. =feed+ +
  • 7. =feed+ + • • •
  • 8. =feed+ +
  • 9. =feed+ + • • • @ • @ •
  • 10. =feed+ +
  • 11. =feed+ + • • • @ • @ •
  • 12. =feed+ +
  • 13. =feed+ + • • • @ • @ •
  • 14. =feed+ +
  • 15. =feed+ + • • • @ • @ •
  • 16. =feed+ +
  • 17. =feed+ + •feed • mysql • mc
  • 18. =feed+ + •
  • 19. =feed+ + • mysql: relation.following • fromuid, touid, addtime • addtime desc select * from following where fromuid=? order by • addtime desc select * from following where touid=? order by • fromuid, touid
  • 20. =feed+ + • mysql: relation.following relation.follower • fromuid, touid, addtime • addtime desc select * from following where fromuid=? order by • desc select * from follower where touid=? order by addtime •
  • 21. =feed+ + • • • • •
  • 22. =feed+ + • ta • ta • ta •
  • 23. =feed+ + • • c/java • • •
  • 24. =feed+ + • redis • hash : • key : user id • fields : friends ids • value : add time
  • 25. =feed+ + • redis • hash : • hset fromuid.following touid addtime • hset touid.follower fromuid addtime • hgetAll fromuid. following • hgetAll touid.follower ? • 11,704,598 @Wed Sep 7 21:46:33 CST 2011
  • 26. =feed+ + • hash-max-zip-size • 64 -> 256 1/3 • cpu • hgetAll cost too much cpu • add mc • high delay
  • 27. =feed+ +
  • 28. =feed+ + • redis • cache ? waste too much mem • storage ? • rdb may lost data • aof r/w too slow, recover too slow • all data in mem, waste money • HA : master slave ? NO WAY • memory fragment
  • 29. =feed+ +
  • 30. =feed+ + • • mysql binlog >> queue >> Java Processor >> redis • mysql binlog >> trigger >> redis
  • 31. =feed+ + • • redis@weibo for now: • TB • growing fast
  • 32. =feed+ + • •@ mysql modified + innodb • following list of a user in one column • still under dev
  • 33. =feed+ + •
  • 34. =feed+ + • • • •@ • •
  • 35. =feed+ +
  • 36. =feed+ + • • • @ • • • js
  • 37. =feed+ + • mc + queue + mysql • mysql • mc mysql • mc
  • 38. =feed+ + • • • • •
  • 39. =feed+ + • redis • k-v , 100 byte per k-v • mc • • hash , hget pipeline slow
  • 40. =feed+ + • redis • rdb ? may lost data • aof ? grow too fast (4G/day) • bgsave/bgrewriteaof influence parent
  • 41. =feed+ +
  • 42. =feed+ + • redis rolling • • • • key
  • 43. =feed+ + • • rediscounter @ • array , not linked list • malloc all mem when start • hash key to position • write disk: asyn & slow down • add position to aof file
  • 44. =feed+ + • • rediscounter + innodb • auto roll cold data to disk
  • 45. =feed+ + • • @TimYang • @XiaoJunHong • • redis (delay) - mc (throughput) - java hash map
  • 46. • cache • storage
  • 47. • • • + •
  • 48. • • / • •
  • 49. • • rdb or aof
  • 50. • • rehash
  • 51. • HA / Cluster • Redis • Jedis
  • 52. • CPU • Redis • hset with big hash-max-zip-size • hgetAll • mc
  • 53. • • • •
  • 54. Thanks @ http://weibo.com/tangfl http://fulin.org
  • 55. Q &A PS. We are hiring ! contact me via @