Mathias Meyer, 22.10.2009Peritor GmbH
Redis - Fast and FuriousN✮SQL Berlin
Donnerstag, 22. Oktober 2009
Self
I work at Peritor in Berlin
I tweet @roidrage
I code at http://github.com/mattmatt
I blog at http://paperplanes.de
2
Donnerstag, 22. Oktober 2009
Peritor
Working on
http://scalarium.com
3
Donnerstag, 22. Oktober 2009
Redis - Key-Value Store
Simple, yet awesome
Fast, yet nonvolatile
code.google.com/p/redis
4
Donnerstag, 22. Oktober 2009
Redis
REmote DIctionary Server
5
Donnerstag, 22. Oktober 2009
Redis
Went public in March 2009
Just reached 1.0
6
Donnerstag, 22. Oktober 2009
Redis
< 6000 lines of code
7
Donnerstag, 22. Oktober 2009
Redis
And the code is simple
8
Donnerstag, 22. Oktober 2009
Redis
No threading, just one process
9
Donnerstag, 22. Oktober 2009
Redis
Like Memcached, only awesome
10
Donnerstag, 22. Oktober 2009
Redis
Simple and efficient text-based protocol
(just like grandma and Memcached used to make)
11
Donnerstag, 22. Oktober 2009
Redis Protocol
12
Donnerstag, 22. Oktober 2009
Redis Protocol
13
redis[“key”] = “value”
Donnerstag, 22. Oktober 2009
Redis Protocol
Duh!
14
Donnerstag, 22. Oktober 2009
Redis Protocol
Values can be strings, lists or sets
15
Donnerstag, 22. Oktober 2009
Redis Protocol - Special Ops
Push and pop elements (atomic)
Fetch arbitrary set and array elements
Sorting
16
Donnerstag, 22. Oktober 2009
Redis Protocol
set foo 4
1000
+OK
17
Donnerstag, 22. Oktober 2009
Redis Protocol
set foo 4
1000
+OK
17
Request
Response
Donnerstag, 22. Oktober 2009
Redis Protocol
get foo
$4
1000
get bar
$-1
18
Donnerstag, 22. Oktober 2009
Redis Protocol
get foo
$4
1000
get bar
$-1
18
Request
Response
RequestResponse
Donnerstag, 22. Oktober 2009
Redis Protocol
incr foo
:1001
type foo
+string
19
Donnerstag, 22. Oktober 2009
Redis Protocol - Lists
lpush pizza 4
fury
+OK
rpush pizza 8
ortolana
+OK
20
Donnerstag, 22. Oktober 2009
Redis Protocol - Lists
lrange pizza 0 1
*2
$4
fury
$8
ortolana
21
Donnerstag, 22. Oktober 2009
Redis Protocol - Lists
lrange pizza 0 1
*2
$4
fury
$8
ortolana
21
Request
Response
Donnerstag, 22. Oktober 2009
Redis Protocol - Sets
sadd mq 8
rabbitmq
:1
sadd mq 6
zeromq
:1
22
Donnerstag, 22. Oktober 2009
Redis Protocol - Sets
smembers mq
*2
$6
zeromq
$8
rabbitmq
23
Donnerstag, 22. Oktober 2009
Redis Protocol - Sets
sort mq alpha
*2
$8
rabbitmq
$6
zeromq
24
Donnerstag, 22. Oktober 2009
Redis Protocol - The Rest
Random list/set access
Intersections, Unions
Monitoring
Controlling the Server
Multi-Set Commands
25
Donnerstag, 22. Oktober 2009
Redis
Data is held in memory, but can be persisted
26
Donnerstag, 22. Oktober 2009
Redis Key-Value Database
Persistent
Asynchronous
Just like Super Pursuit Mode
27
Donnerstag, 22. Oktober 2009
Redis Database
Data is written to disk asynchronously
28
Donnerstag, 22. Oktober 2009
Redis Database
29
Redis Server
Redis Serverfork()
Dump Database
exit()
rename()
Donnerstag, 22. Oktober 2009
Redis Database
save 900 1
save 300 10
save 60 100000
30
Donnerstag, 22. Oktober 2009
Replication
1 Master - N Slaves
Asynchronous on Master
Synchronous on Slave
31
Donnerstag, 22. Oktober 2009
Redis ReplicationLike dumping the database, only to a different file descriptor.
32
Donnerstag, 22. Oktober 2009
Redis Master
Redis Slave Redis Slave
Redis SlaveRedis Slave
Redis Replication
33
Donnerstag, 22. Oktober 2009
Redis - Scaling
Horizontal• Run multiple Redis processes
• Use HashRing (e.g. in redis-rb)
34
Donnerstag, 22. Oktober 2009
Redis - Scaling
Vertical• Master-Slave setup
• Fetch data from any slave (e.g. random)
35
Donnerstag, 22. Oktober 2009
To Redis, or not to Redis?
36
Donnerstag, 22. Oktober 2009
As always, it depends
37
Donnerstag, 22. Oktober 2009
To Redis
38
CachingStatistical dataRecoverable stateWorker queue
Donnerstag, 22. Oktober 2009
Not to Redis
100% consistent dataset requiredData is larger than memory
39
Donnerstag, 22. Oktober 2009
Redis Use Cases
Nanite - A self-assembling cluster of Ruby daemons
40
Donnerstag, 22. Oktober 2009
The most important question!
41
Donnerstag, 22. Oktober 2009
Is it faster than Memcached?
42
Donnerstag, 22. Oktober 2009
No, but fast enough for you(if you need the extra features)
43
Donnerstag, 22. Oktober 2009
Redis
44
Simple, fast, awesome.
Donnerstag, 22. Oktober 2009
Questions?
45
Donnerstag, 22. Oktober 2009
© Peritor GmbH - Alle Rechte Vorbehalten
Peritor GmbHBlücherstr. 22, Hof III Aufgang 610961 Berlin
Tel.: +49 (0)30 69 20 09 84 0Fax: +49 (0)30 69 20 09 84 9
Internet: www.peritor.comE-Mail: [email protected]
Donnerstag, 22. Oktober 2009