Real World RedisAra AnjargolianCo-Founder & C TO, YCharts
The typical SQL/NoSQL breakdown            SQL                          NoSQL      Single machine         Multi-machine / ...
So what is Redis?Redis is often called a data structure server.That is, a database that hosts a set of handy datastructure...
Where does Redis fit in?           Redis                           NoSQL  Single machine, for now.     Multi-machine / Dist...
Introducing Redis into yourproduction environment.•   Step 1: Find one cool use case for Redis.•   Step 2: Implement and d...
Data structures•   Key/value•   Lists•   Sets•   Sorted Set•   Hashes•   Pub/sub
Key/valueFunctionality•   Basic set/get•   Keys can expire or not•   Atomic increment/decrementUse cases•   Store sparse/o...
ListsFunctionality•   Atomic push/pop•   Set/get by index.•   Sort.Use cases•   We use it as a queue backend. See hotqueue...
SetsFunctionality•   Add/remove.•   Intersect, union, intersect + store, union + store.•   Sort.Use cases•   We use it to ...
Sorted setsFunctionality•   Add/remove/get rank by score.•   Get/remove range of members, by score or reversed    score.• ...
HashesFunctionality•   Set/delete field of hash.•   Set/get multiple fields of hash.•   Increment field.Use cases•   Tabular ...
Pub/subFunctionality•   Multiple clients can listen for messages published on    a named channelUse cases•   Streaming / r...
Other cool stuff•   Transactions. Atomic execution of multiple    commands.•   Variadic functions. Lots of operations, for...
Deployment notes•   Most importantly: Redis is very fast and stable.•   Compile from source. Code too fast to use OS    pa...
The future•   Redis 2.6. Lua scripting for advanced operations.•   Redis-cluster. Multi-machine / distributed Redis.    Be...
The end.Questions or comments? Contact ara @ ycharts.comp.s. YCharts is hiring!
Upcoming SlideShare
Loading in …5
×

Real World Redis

10,843 views

Published on

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

No Downloads
Views
Total views
10,843
On SlideShare
0
From Embeds
0
Number of Embeds
8,005
Actions
Shares
0
Downloads
50
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Real World Redis

    1. 1. Real World RedisAra AnjargolianCo-Founder & C TO, YCharts
    2. 2. The typical SQL/NoSQL breakdown SQL NoSQL Single machine Multi-machine / Distributed Non-relational, references Relational possible Key-value, column-store, Tables document store On disk storage + cache. On disk storage + cache. ACID BASE (Atomicity, Consistency, (Basically available, Soft state, Isolation, Durability) Eventual consistency
    3. 3. So what is Redis?Redis is often called a data structure server.That is, a database that hosts a set of handy datastructures and extremely useful operations on saidstructures.
    4. 4. Where does Redis fit in? Redis NoSQL Single machine, for now. Multi-machine / Distributed Non-relational, references Non-relational possible Key-value, column store, Key-value+++ document storeIn memory + disk persistence On disk storage + cache. BASE RDB dump. AOF. Or both. (Basically available, Soft state, Eventual consistency)
    5. 5. Introducing Redis into yourproduction environment.• Step 1: Find one cool use case for Redis.• Step 2: Implement and deploy• Step 3: Find 5 other ways where Redis gives your app/company a unique advantage.At YCharts, we use Redis in 6 distinct,unrelated ways.
    6. 6. Data structures• Key/value• Lists• Sets• Sorted Set• Hashes• Pub/sub
    7. 7. Key/valueFunctionality• Basic set/get• Keys can expire or not• Atomic increment/decrementUse cases• Store sparse/one off data: We use it store global site settings that we wan’t to change on the fly.• Cache backends: People use it as memcached replacement, or to save user sessions.• Really fast, hit counters. Think logging, monitoring, etc.
    8. 8. ListsFunctionality• Atomic push/pop• Set/get by index.• Sort.Use cases• We use it as a queue backend. See hotqueue or celery.
    9. 9. SetsFunctionality• Add/remove.• Intersect, union, intersect + store, union + store.• Sort.Use cases• We use it to intersects lists of stocks for screening functionality of our site.• Good for anything else sets might be used for normally.
    10. 10. Sorted setsFunctionality• Add/remove/get rank by score.• Get/remove range of members, by score or reversed score.• Union/intersect.Use cases• Autocompleters that sort by arbitrary metric. We use them for fast autocompleter that sorts by company market cap.• Really fast range queries. We use it for filtering metrics on our stock screener.• Leaderboards for games.
    11. 11. HashesFunctionality• Set/delete field of hash.• Set/get multiple fields of hash.• Increment field.Use cases• Tabular or column oriented data.• We use it to store output of various site usage reports. Also use it, in essence, as key space for autocompleter.
    12. 12. Pub/subFunctionality• Multiple clients can listen for messages published on a named channelUse cases• Streaming / real-time data.• Stock quotes: One channel per stock symbol ... multiple browser client listeners. We will use it soon for this!• Alerts: One channel / user.
    13. 13. Other cool stuff• Transactions. Atomic execution of multiple commands.• Variadic functions. Lots of operations, for examples Adding a member to a set or list, have versions where you can add multiple items at once.• Pipelining. To avoid constant network back/forth, commands in Redis can be grouped together and results gotten back in one response. Basically can fake variadic behavior w/o having actual variadic functions.
    14. 14. Deployment notes• Most importantly: Redis is very fast and stable.• Compile from source. Code too fast to use OS packaged versions.• Remember it’s a memory DB, so must have as much memory as data you’re going to hold.• It’s fast out of the box, tuning is more command level then system level.• Most important system setting is level of data persistence.• To optimize, make sure you are using variadic functionality, and where not available, pipelining.• Replication is an option for data durability.
    15. 15. The future• Redis 2.6. Lua scripting for advanced operations.• Redis-cluster. Multi-machine / distributed Redis. Being (very) actively developed.
    16. 16. The end.Questions or comments? Contact ara @ ycharts.comp.s. YCharts is hiring!

    ×