More than just a key value datastore




                               Christopher Spring
What is redis?
remote dictionary server
remote dictionary server

   'Key'   =>   String
   'Key'   =>   Set
   'Key'   =>   Hash
   'Key'   =>   List
   'Key'   =>   Sorted Set
Key features
Key features
Key features


Cheap API for lists, sets...
Key features


Cheap API for lists, sets...
Atomic operations
Key features


Cheap API for lists, sets...
Atomic operations
Transactions
Key features


Cheap API for lists, sets...
Atomic operations
Transactions
Key expiry
In memory storage
In memory storage


Single process event driven design
In memory storage


Single process event driven design
Non blocking
In memory storage


Single process event driven design
Non blocking
100k+ operations per second
Asynchronous persistence
Asynchronous persistence

       Snapshotting

        save 60 1000
Asynchronous persistence

       Snapshotting

        save 60 1000
       Append only file
        Log rewriting
        fsync
Master slave replication
   slaveof '192.168.1.1' 6379
Master slave replication
   slaveof '192.168.1.1' 6379


    Multiple slaves
Master slave replication
   slaveof '192.168.1.1' 6379


    Multiple slaves
    Slaves of slaves
Master slave replication
   slaveof '192.168.1.1' 6379


    Multiple slaves
    Slaves of slaves
    Scalability
Master slave replication
   slaveof '192.168.1.1' 6379


    Multiple slaves
    Slaves of slaves
    Scalability
    Defer save to slaves
Redis Virtual Memory
Redis Virtual Memory


Only values swapped out to disk
Redis Virtual Memory


Only values swapped out to disk
Most recent values in memory
Redis Virtual Memory


Only values swapped out to disk
Most recent values in memory




       ...disk store
Message pub/sub
Message pub/sub

Messages are published to channels
PUBLISH chat "Hello Redis!"
Message pub/sub

Messages are published to channels
PUBLISH chat "Hello Redis!"

Subscribers declare which channels they’re interested in
SUBSCRIBE chat
Message pub/sub

Messages are published to channels
PUBLISH chat "Hello Redis!"

Subscribers declare which channels they’re interested in
SUBSCRIBE chat

Subscribers and publishers don’t care about each other
Message pub/sub

Messages are published to channels
PUBLISH chat "Hello Redis!"

Subscribers declare which channels they’re interested in
SUBSCRIBE chat

Subscribers and publishers don’t care about each other
Supports pattern subscription
PSUBSCRIBE f*
There are only two hard
things in computer science...
DB + caching
DB + caching




Multiple copies of data
DB + caching




Multiple copies of data
Mainly scaling reads
DB + caching




Multiple copies of data
Mainly scaling reads
No higher level functions
Redis
How we use redis
How we use redis


Statistics & Caching
How we use redis


Statistics & Caching
Queueing
How we use redis


Statistics & Caching
Queueing
Throttling
How we use redis


Statistics & Caching
Queueing
Throttling
Inter process communication*
When to consider redis
When to consider redis


You like it fast
When to consider redis


You like it fast
You need more than just key value pairs
When to consider redis


You like it fast
You need more than just key value pairs
Small dataset that can fit into memory
When to consider redis


You like it fast
You need more than just key value pairs
Small dataset that can fit into memory
Your dataset isn’t critical*
•   C             •   Java

•   C#            •   Lua

•   C++           •   Node.js

•   Clojure       •   Objective-c

•   Common List   •   Perl

•   Erlang        •   PHP

•   Go            •   Python

•   Haskell       •   Scala

•   haXe          •   Smalltalk

•   Io            •   Tcl
Thanks!

Redis overview for Software Architecture Forum

Editor's Notes

  • #2 \n
  • #3 \n
  • #4 \n
  • #5 \n
  • #6 \n
  • #7 \n
  • #8 \n
  • #9 \n
  • #10 \n
  • #11 \n
  • #12 \n
  • #13 Snapshotting: periodically dump entire dataset to disk\n- Not durable, can lose latest data\n- every 60 seconds if there have been 1000 key changes...\n\nAOF: Append commands to a log\n- log rewriting \n- fully durable: fsync per command (slow & safe), every second (fast & pretty safe) or never (blazing & unsafe)\n\nfsync -- synchronize a file's in-core state with that on disk\n
  • #14 Snapshotting: periodically dump entire dataset to disk\n- Not durable, can lose latest data\n- every 60 seconds if there have been 1000 key changes...\n\nAOF: Append commands to a log\n- log rewriting \n- fully durable: fsync per command (slow & safe), every second (fast & pretty safe) or never (blazing & unsafe)\n\nfsync -- synchronize a file's in-core state with that on disk\n
  • #15 \n
  • #16 \n
  • #17 \n
  • #18 \n
  • #19 Redis virtual memory going to be scrapped in favour of disk storage\n\nBoth keys and values will be backed by disk\n
  • #20 Redis virtual memory going to be scrapped in favour of disk storage\n\nBoth keys and values will be backed by disk\n
  • #21 Redis virtual memory going to be scrapped in favour of disk storage\n\nBoth keys and values will be backed by disk\n
  • #22 \n
  • #23 \n
  • #24 \n
  • #25 \n
  • #26 ...cache invalidation and naming things\n\nPhil Karlton\n
  • #27 \n
  • #28 \n
  • #29 \n
  • #30 \n
  • #31 \n
  • #32 \n
  • #33 \n
  • #34 \n
  • #35 \n
  • #36 \n
  • #37 \n
  • #38 \n
  • #39 \n
  • #40 \n
  • #41 \n