SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
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 @

Contenu connexe

Tendances

Data Intelligence 2017 - Building a Gigaword Corpus
Data Intelligence 2017 - Building a Gigaword CorpusData Intelligence 2017 - Building a Gigaword Corpus
Data Intelligence 2017 - Building a Gigaword Corpus
Rebecca Bilbro
 
Hortonworks HBase Meetup Presentation
Hortonworks HBase Meetup PresentationHortonworks HBase Meetup Presentation
Hortonworks HBase Meetup Presentation
Hortonworks
 
Building a Gigaword Corpus (PyCon 2017)
Building a Gigaword Corpus (PyCon 2017)Building a Gigaword Corpus (PyCon 2017)
Building a Gigaword Corpus (PyCon 2017)
Rebecca Bilbro
 
Redis Introduction
Redis IntroductionRedis Introduction
Redis Introduction
Alex Su
 
Apache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux FestApache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux Fest
Myles Braithwaite
 

Tendances (20)

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

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

Tup2 新浪杨卫华
Tup2 新浪杨卫华Tup2 新浪杨卫华
Tup2 新浪杨卫华
yongboy
 
S2weibocachearch 100726101949-phpapp02
S2weibocachearch 100726101949-phpapp02S2weibocachearch 100726101949-phpapp02
S2weibocachearch 100726101949-phpapp02
batistuta97
 
超カジュアルに使うMySQL @ MySQL Casual Talks #2
超カジュアルに使うMySQL @ MySQL Casual Talks #2超カジュアルに使うMySQL @ MySQL Casual Talks #2
超カジュアルに使うMySQL @ MySQL Casual Talks #2
Tasuku Suenaga
 
Inside Of Mbga Open Platform
Inside Of Mbga Open PlatformInside Of Mbga Open Platform
Inside Of Mbga Open Platform
Hideo Kimura
 
BuilHigh Performance Weibo Platform-Qcon2011
BuilHigh Performance Weibo Platform-Qcon2011BuilHigh Performance Weibo Platform-Qcon2011
BuilHigh Performance Weibo Platform-Qcon2011
Yiwei Ma
 
Open Network Live - Hack Day Report
Open Network Live - Hack Day ReportOpen Network Live - Hack Day Report
Open Network Live - Hack Day Report
Open Network Lab
 

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

Redis 坑
Redis 坑Redis 坑
Redis 坑
 
Tup2 新浪杨卫华
Tup2 新浪杨卫华Tup2 新浪杨卫华
Tup2 新浪杨卫华
 
杨卫华:微博cache设计浅谈
杨卫华:微博cache设计浅谈杨卫华:微博cache设计浅谈
杨卫华:微博cache设计浅谈
 
Blazing Data With Redis (and LEGOS!)
Blazing Data With Redis (and LEGOS!)Blazing Data With Redis (and LEGOS!)
Blazing Data With Redis (and LEGOS!)
 
S2weibocachearch 100726101949-phpapp02
S2weibocachearch 100726101949-phpapp02S2weibocachearch 100726101949-phpapp02
S2weibocachearch 100726101949-phpapp02
 
超カジュアルに使うMySQL @ MySQL Casual Talks #2
超カジュアルに使うMySQL @ MySQL Casual Talks #2超カジュアルに使うMySQL @ MySQL Casual Talks #2
超カジュアルに使うMySQL @ MySQL Casual Talks #2
 
Inside Of Mbga Open Platform
Inside Of Mbga Open PlatformInside Of Mbga Open Platform
Inside Of Mbga Open Platform
 
如何构建一个高可用可扩展的广告投放平台-品友互动
如何构建一个高可用可扩展的广告投放平台-品友互动 如何构建一个高可用可扩展的广告投放平台-品友互动
如何构建一个高可用可扩展的广告投放平台-品友互动
 
BuilHigh Performance Weibo Platform-Qcon2011
BuilHigh Performance Weibo Platform-Qcon2011BuilHigh Performance Weibo Platform-Qcon2011
BuilHigh Performance Weibo Platform-Qcon2011
 
High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011
 
下吧开发总结
下吧开发总结下吧开发总结
下吧开发总结
 
Using HAProxy to Scale MySQL
Using HAProxy to Scale MySQLUsing HAProxy to Scale MySQL
Using HAProxy to Scale MySQL
 
龍華大學前端技術分享 Part1
龍華大學前端技術分享 Part1龍華大學前端技術分享 Part1
龍華大學前端技術分享 Part1
 
Nodejsvault austin2019
Nodejsvault austin2019Nodejsvault austin2019
Nodejsvault austin2019
 
Open Network Live - Hack Day Report
Open Network Live - Hack Day ReportOpen Network Live - Hack Day Report
Open Network Live - Hack Day Report
 
Python教程 / Python tutorial
Python教程 / Python tutorialPython教程 / Python tutorial
Python教程 / Python tutorial
 
Top ten-list
Top ten-listTop ten-list
Top ten-list
 
Python redis talk
Python redis talkPython redis talk
Python redis talk
 
PostgreSQL 9.4: NoSQL on ACID
PostgreSQL 9.4: NoSQL on ACIDPostgreSQL 9.4: NoSQL on ACID
PostgreSQL 9.4: NoSQL on ACID
 
Kiosk / PHP
Kiosk / PHP Kiosk / PHP
Kiosk / PHP
 

Plus de fulin tang

基于Lucene的站内搜索
基于Lucene的站内搜索基于Lucene的站内搜索
基于Lucene的站内搜索
fulin tang
 
基于Lucene的站内搜索
基于Lucene的站内搜索基于Lucene的站内搜索
基于Lucene的站内搜索
fulin tang
 

Plus de fulin tang (14)

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

Dernier

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

新浪微博开放平台中的 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 @