1. Einführung &
Use Cases
Sebastian Cohnen
@tisba / tisba.de
Donnerstag, 3. Mai 12
2. About Me
• Freier Entwickler
❤ Ruby/Rails & node.js
❤ Performance & Scalability Engineering
❤ Distributed Load Testing
❤ CouchDB, Redis & Riak
und ebenfalls interessiert an Erlang, AMQP, ...
Donnerstag, 3. Mai 12
3. Redis
von Salvatore “antirez” Sanfilippo
erste Version ~04/2009
aktuell 2.4.13 (stable) / 2.6.0-rc2
Donnerstag, 3. Mai 12
4. Was ist Redis?
memcached Ersatz?
memcached on steriods?
Caching Server?
KV-Storage?
...?
Donnerstag, 3. Mai 12
5. ...!
in-memory Datenbank (KV Store)
Datentypen: String, Hash, List, Set & sorted Set
Master-Slave Replikation
Transaktionen
ASCII-basiertes Protokoll
Donnerstag, 3. Mai 12
6. Getting Started
http://redis.io/download
zum Spielen 2.6.x – für Live-Systeme 2.4.x
brew install redis (apt-get install redis)
$ redis-cli
> SET myval "bar"
OK
> GET myval
"bar"
Donnerstag, 3. Mai 12
9. Listen
Sortierte Liste aus Strings
[L|R]POP, [L|R]PUSH
LINSERT mylist BEFORE|AFTER “foo”
LTRIM, LRANGE, RPOPLPUSH
Donnerstag, 3. Mai 12
10. Hashes
Hash Map mit Key und Value, jeweils Strings
z.B. zum Abbilden von Objekten
direkter Zugriff auf einzelne, mehrere oder alle
Attribute
HGET, HMGET, HGETALL
HSET, HMSET
HKEYS, HVALS, HLEN
Donnerstag, 3. Mai 12
17. Benchmarks sind
doof ;)
redis-benchmark -P 64 -n 1000000
-t incr,get,set
=> 370k SET/s | 450k GET/s | 347k INCR/s
in bisherigen Tests sind dauerhafte 30k OPS/s auf EC2
kein Problem (YMMV)
http://redis.io/topics/benchmarks
Donnerstag, 3. Mai 12
18. Performance
generell gute, stabile Latenzen & guter Durchsatz
algorithmische Komplexität ist gut dokumentiert
Optimierung ist oft einfach
Wichtig
Pipelining nutzen
Domain Socket vs. TCP Socket
Donnerstag, 3. Mai 12
24. Weitere Use Cases
Visitor/Event Tracking
LRU Cache
Scoreboard/Leaderboard
Donnerstag, 3. Mai 12
25. 1st class DB
Integraler Bestandteil / Erweiterung der
Anwendungslogik
Sets, Lists und Hashes um spezielle Aufgaben zu lösen
alle Requests aus Redis (“live cache”)
Datenbank als Fallback
Donnerstag, 3. Mai 12
26. Resources
Infos zu Redis & Dokumentation: http://redis.io/
Blog von Salvatore: http://antirez.com
https://groups.google.com/forum/#!topic/redis-db/
d4QcWV0p-YM
http://highscalability.com/blog/2012/4/2/youporn-
targeting-200-million-views-a-day-and-beyond.html
Donnerstag, 3. Mai 12
27. Thanks! Q & A?
?
Sebastian Cohnen
@tisba
Donnerstag, 3. Mai 12