Performance Degrading
= Unhappy User
= Less Profit
Slide 9
Slide 9 text
Complex Queries
Inefficient schema
Slide 10
Slide 10 text
Limited Time
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
Just
ADD it
to your
stack
Slide 13
Slide 13 text
Just
ADD it
to your
stack
Not Replace
Slide 14
Slide 14 text
Special
Performance
Simple
In-memory
Atomic
Slide 15
Slide 15 text
Special
Performance
Simple
In-memory
Atomic
Slide 16
Slide 16 text
Management Problem
a.k.a. “We don’t have a MIS”
Slide 17
Slide 17 text
Dependency
Feb 25, 2009
First public beta
Oct 14, 2011
Redis 2.4
First external dependency
jemalloc
Mar 31, 2012
Slide 18
Slide 18 text
Installation
Feb 25, 2009
First public beta
Oct 14, 2011
Redis 2.4
First external dependency
jemalloc
Mar 31, 2012
make install make install
Slide 19
Slide 19 text
Stable
Slide 20
Slide 20 text
No content
Slide 21
Slide 21 text
Special
Performance
Simple
In-memory
Atomic
Slide 22
Slide 22 text
Special
Performance
Simple
In-memory
Atomic
Slide 23
Slide 23 text
In-Memory
Memcached
High Performance
Simple Key-Value
Redis
In-Memory
High Performance
Data Structures
Persistence
Replication
...
Slide 24
Slide 24 text
Data Structures
List, Set, Sorted Set, Hash, String
http://redis.io/commands
Slide 25
Slide 25 text
Understand your problem
http://nosql.mypopescu.com/post/18977451039/redis-guide-what-each-redis-data-type-should-be-used
Every command in Redis is
manipulating a data structure
Slide 26
Slide 26 text
Special
Performance
Simple
In-memory
Atomic
Slide 27
Slide 27 text
Special
Performance
Simple
In-memory
Atomic
Slide 28
Slide 28 text
=
Slide 29
Slide 29 text
http://redis.io/topics/benchmarks
FAST
for real
Slide 30
Slide 30 text
Special
Performance
Simple
In-memory
Atomic
Slide 31
Slide 31 text
No Race Condition
every command in redis is atomic
use redis as a incremental counter
“There are very few systems that support an “increment and return” operation,
and Redis is one of them (Oracle sequences are another).”
http://nateware.com/2010/02/18/an-atomic-rant/
Slide 32
Slide 32 text
No Race Condition
every command in redis is atomic
Combine multiple command: still atomic!
MULTI
SET key 123
SET key2 456
EXEC
Warning: Don’t confuse with transaction
Slide 33
Slide 33 text
Special
Performance
Simple
In-memory
Atomic
Slide 34
Slide 34 text
i
Slide 35
Slide 35 text
Did I make any changes to MySQL?
NO
It’s still our main database
Slide 36
Slide 36 text
Did I solve the problem?
YES
solve complex queries via Redis data structure
Slide 37
Slide 37 text
Happy Database
Add Redis to stack
Slide 38
Slide 38 text
How?
Sorted Set: Per user notification
String: API request limiter
String, List: Request logging
List: Job Queue
Slide 39
Slide 39 text
Real World = Risk
Persistence Replication Sharding
Slide 40
Slide 40 text
Persistence
RDB
AOF
Slide 41
Slide 41 text
RDB
• Snapshot
• Compact
• .rdb file can be transfered to other
backup system
• Chances to lose data
Slide 42
Slide 42 text
AOF
• logs of every write operation
• durable
• bigger file size
Slide 43
Slide 43 text
You want a degree of safety
comparable to PostgreSQL?
Just use BOTH
Slide 44
Slide 44 text
Replication
Master
Slave
Slave
Slave
Slide 45
Slide 45 text
Replication
• Read-only salves
• Save on slaves
Slide 46
Slide 46 text
Sharding
• Memory is limited
• Split data into multiple redis servers