8. Publish–subscribe
Redis supports publish-subscribe mode.
You can subscribe some topics, and
when someone publish topic matches
your interest, redis send it to you.
9. Lua scripting
Scripting makes Redis much faster for
complex operations
read-compute-write workflow
10. Pipelining
NOT Redis transactions
Does not provide atomicity
Nothing more complicated than the fact
that Redis server is able to queue up
responses in memory
Too many commands in a single pipeline
may cause memory issues and potentially
socket timeout.
Benchmark
without pipelining 1.185238 seconds
with pipelining 0.250783 seconds
11. Transactions
All the commands in a transaction are
serialized and executed sequentially.
Either all of the commands or none are
processed.
Redis does not support roll backs
A command fails to be queued
A command fails after EXEC is called(not
supported)
12. More use cases
Leader election
Counting semaphores
Queue
Pizza topping problem
13. Persistence
Virtual Memory
RDB (Snapshots)
Take snapshot in an interval
Fast
May loss several minutes data if kill -9
Append Only File (AOF)
Log-based link binlog, redo whole steps since
startup
Auto bgrewriteaof (background rewrite AOF)
Still fast enough
May loss 1 second data if kill -9
14. Replication
Official Master-slave replication
Write in Master, Read in Slaves
Replication
• Official Master-slave replication
– Write in Master, Read in Slaves
15. Partitioning
Redis Cluster is currently not production
ready.
Redis Cluster is a mix between query
routing and client side partitioning.
16. High Availability
Redis Sentinel is a system designed to
help managing Redis instances. It
performs the following three tasks:
Monitoring
Notification
Automatic failover
Not good for production environments
19. Twemproxy
Maintain persistent server connections
Keep connection count on cache servers low
Pipeline requests and responses
Use multiple server pools simultaneously
Proxy the complete memcached ASCII
protocol
Easily configure server pools using a YAML file
Use multiple hashing modes, including
consistent hashing
Increase observability using stats exposed on
a monitoring port
25. Compare with Memcached
Memcached Redis
(Multi)Get V V
(Multi)Set V V
Incr/Decr V V
Deletion V V
Expiration V V
Range Queries V
Data Types V
Persistence V
Replication V
Prepend/Append V
勝
勝
勝
勝
勝
26. Reference
Redis Commands
Is memcached a dinosaur in
comparison to Redis?
Redis Failover at Spreecast Based on
Apache ZooKeeper
twemproxy