Redis

3,275 views
3,135 views

Published on

A brief introduction to Redis I gave at Seattle Tech Startups meetup on November 11, 2010. Provides some example use cases.

Published in: Technology, Health & Medicine
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,275
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
38
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Redis

  1. 1. Redis Damon Cortesi (@dacort) Untitled Startup (RowFeeder)
  2. 2. Movember • Help support prostate cancer research • http://bit.ly/mo_dacort
  3. 3. Up and Running • wget http://redis.googlecode.com/files/ redis-2.0.4.tar.gz • tar xzvf redis-2.0.4.tar.gz • cd redis-2.0.4 • make • ./redis-server
  4. 4. Yes...that’s it • Redis in your browser • http://try.redis-db.com • http://code.google.com/p/redis/wiki/ CommandReference
  5. 5. http://try.redis-db.com
  6. 6. 101 • Key/Value Store on Steroids • memcache? • Persistent • Push/Pop • Data types • Fast - 110000 SETs/sec, 81000 GETs/sec
  7. 7. Redis Data Types • Strings • Lists • Sets • Sorted/Scored Sets • Hashes
  8. 8. But wait, there’s more! • Clustering • Replication • Master/Slave • Publish/Subscribe
  9. 9. Use Cases • Queue Processing • Set Intersection • Stats Tracking/Leaderboards
  10. 10. Keyword Filter Geo Filter Other Custom Filters Resque Queue (redis) Resque Workers MongoDB Status Storage External Data Tagging - bit.ly, geo, klout rowfeeder.com MySQL User & Track Data Slave MySQL Geo Lookups Memcache Web Status Processing Google Spreadsheet
  11. 11. Queues • Resque - Killer Ruby library for background jobs • RowFeeder - 428,811,359 items processed a b c d LPOP RPUSH
  12. 12. Set Intersections • Goal: Contact Ashton Kutcher on Twitter • Approach: Is there anybody I can DM that can DM Ashton, or a friend of his?
  13. 13. Step 1 • Are any of my followers his friends? • SADD - Add specified member to the set • SINTER - Intersection of N sets
  14. 14. Step 2 • Can I DM somebody that can DM a friend of his? • ?t ?
  15. 15. Sweet!
  16. 16. Scoreboards • Sorted ZSets • ZINCRBY - Increment Operator • ZRANGE - Sort + Subset
  17. 17. • Tracks Twitter/Facebook Posts • ~4,000 keywords monitored in real-time • ~2MM posts/day • Sometimes...
  18. 18. What’s Blowing Up?
  19. 19. Step 1 • Maintain counters of all matched terms • Increment the “stream::kw::time” key by 1
  20. 20. Step 2 • 5 minute running average of the top 10 terms
  21. 21. Limitations • Greedy with memory • If it grows to XGB...it will stay there • (Not optimal if a queue backs up) • All in RAM / Atomicity • 2.0 solves both of these! • NoSQL
  22. 22. Questions • @dacort • damon [at] untitledstartup.com

×