Upload
damon-cortesi
View
2.964
Download
2
Embed Size (px)
DESCRIPTION
A brief introduction to Redis I gave at Seattle Tech Startups meetup on November 11, 2010. Provides some example use cases.
Citation preview
RedisDamon Cortesi (@dacort)
Untitled Startup (RowFeeder)
Movember
• Help support prostate cancer research
• http://bit.ly/mo_dacort
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
Yes...that’s it
• Redis in your browser
• http://try.redis-db.com
• http://code.google.com/p/redis/wiki/CommandReference
101
• Key/Value Store on Steroids
• memcache?
• Persistent
• Push/Pop
• Data types
• Fast - 110000 SETs/sec, 81000 GETs/sec
Redis Data Types
• Strings
• Lists
• Sets
• Sorted/Scored Sets
• Hashes
But wait, there’s more!
• Clustering
• Replication
• Master/Slave
• Publish/Subscribe
Use Cases
• Queue Processing
• Set Intersection
• Stats Tracking/Leaderboards
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 MySQLGeo Lookups
Memcache
Web Status Processing
GoogleSpreadsheet
Queues
• Resque - Killer Ruby library for background jobs
• RowFeeder - 428,811,359 items processed
a b c d
LPOP
RPUSH
Set Intersections
• Goal: Contact Ashton Kutcher on Twitter
• Approach: Is there anybody I can DM that can DM Ashton, or a friend of his?
Step 1
• Are any of my followers his friends?
• SADD - Add specified member to the set
• SINTER - Intersection of N sets
Step 2
• Can I DM somebody that can DM a friend of his?
• ?t
?
Sweet!
Scoreboards
• Sorted ZSets
• ZINCRBY - Increment Operator
• ZRANGE - Sort + Subset
• Tracks Twitter/Facebook Posts
• ~4,000 keywords monitored in real-time
• ~2MM posts/day
• Sometimes...
What’s Blowing Up?
Step 1
• Maintain counters of all matched terms
• Increment the “stream::kw::time” key by 1
Step 2
• 5 minute running average of the top 10 terms
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
Questions
• @dacort
• damon [at] untitledstartup.com