Getting up to speed with Redis

(NDC London, 2014)

@marcgravell

marc@stackoverflow.com

http://blog.marcgravell.com

Contents

  • introduction and motivations
  • the server
  • the client
  • feature examples
  • redis cluster
  • summary

introduction and motivations

  • key-value store
  • nosql database
  • high performance
  • scaleable
  • in-memory
  • single-threaded

core data structures

  • strings
  • hashes
  • lists
  • sets
  • sorted sets
  • …simple data; powerful operations

additional features

  • pub/sub channel-based distribution
  • transactions
  • scripting
  • replication
  • fast
  • no, really fast

the server

http://redis.io/download

$ wget http://download.redis.io/releases/redis-2.8.18.tar.gz
$ tar xzf redis-2.8.18.tar.gz
$ cd redis-2.8.18
$ sudo make install
                        

PM> Install-Package Redis-64

C:\> cinst redis-64

apt-get install redis

or host in the cloud

  • Microsoft: Azure Redis Cache
  • Redis Labs: Redis Cloud
  • Amazon: ElastiCache
  • and others

opserver

  • multi-purpose monitoring tool
  • inbuilt support for SQL
  • inbuilt support for Redis

https://github.com/opserver/Opserver

the client

http://redis.io/clients

clients (often more than one) for most frameworks…

…and simple (ish) protocol to write for new platforms

PM> Install-Package StackExchange.Redis PM> Install-Package StackExchange.Redis.StrongName

feature examples

show me teh codez!

  • basic usage
  • performance
  • hyperloglog
  • scripting and transactions
  • pub/sub

redis cluster

Single Master

Master / Slave

Chained Slaves

Sharded

Proxied

Cluster

cluster features

  • distributed keyspace
  • live resharding
    • redirection (not proxying)
  • HA fault tolerance
  • node discovery
  • "hash tags" allow same-node control: "{/users/12345}/balance" vs "{/users/12345}/credits"

cluster restrictions

  • requires cluster-aware client
  • multiple databases not supported
  • all multi-key commands must be on same node
  • some commands must now be considered per-server
    • keys, scan, flushdb, flushall

summary

  • described what redis is
  • described the key features
  • installed the server
  • installed the client
  • ran some code
  • looked to the future

Questions?

These slides are available:
http://marcgravell.com/

Or, contact me:

@marcgravell

marc@stackoverflow.com

http://marcgravell.blogspot.com