Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
REDIS
Is it Memcached with persistence and more data types?
Prabhu Missier
Samvit Software Solutions
Melbourne, Australia
What is REDIS
• An in-memory nosql data structure store vs Memcached is a key/value store
• Caching is just one of its opt...
What is REDIS
• Generally used as a persistent data store with LRU configured when it reaches
maximum capacity
• Can selec...
REDIS – Memory Management
• Has no fixed Max Memory limit on the cache instance
• By default uses the jemalloc memory allo...
MEMCACHED- Memory Mgmt
• Allocates one large chunk of memory. The max page size is 1MB
• Uses its own slab-allocator and r...
Slab Allocation
• Frequent initialization and destruction of kernel objects can hamper
performance.
• When an object is de...
Where does REDIS make sense
• Handles variety of formats : lists, sets, array
• Working with sorted sets in memory. It bea...
REDIS pros
• Works better with a geographically distributed cache, say AWS zones
• Pipelining helps in multiple operations...
REDIS cons
• SENTINEL which controls slave-master promotion is unstable. If it fails
then failover from slave-master fails...
Where does MEMCACHED make sense
• Database queries, reduce read load on databases
• Page fragments
• REST round trips
MEMCACHED pros and cons
• PROS
• Low complexity, easy to configure, simple to cluster since a hashing algo is used by the ...
MEMCACHED pros and cons
• MEMCACHED is supposed to perform better when there are concurrent
requests
• Eviction policy is ...
A word on clustering
Consistent hashing on Memcached is still a more robust model for graceful
failure (at least if you ar...
References
• http://www.bigdatalittlegeek.com/blog/2014/3/25/memcached-vs-redis
• http://www.bogotobogo.com/DevOps/Redis/R...
Upcoming SlideShare
Loading in …5
×

Redis - A comparative study with Memcached

298 views

Published on

A brief comparative study of Redis and Memcached, their pros and cons, some use case scenarios, the memory management model used in both and a note on clustering.

Based on research done on the Internet. This presentation will be updated as I get more info on Redis/Memcached

Published in: Software
  • Be the first to comment

  • Be the first to like this

Redis - A comparative study with Memcached

  1. 1. REDIS Is it Memcached with persistence and more data types? Prabhu Missier Samvit Software Solutions Melbourne, Australia
  2. 2. What is REDIS • An in-memory nosql data structure store vs Memcached is a key/value store • Caching is just one of its options • Several powerful data-types such as Hashes, Sorted Sets • Persistence to disk • In-built cluster support • By default is not LRU • Values can be upto 512MB in size vs 1MB for Memcached
  3. 3. What is REDIS • Generally used as a persistent data store with LRU configured when it reaches maximum capacity • Can selectively delete items in the cache • Suitable for Key -> someObject scenarios as opposed to Key -> string Memcached scenarios • Can selectively invalidate items in the cache • REDIS is limited to a single core but now with 3.0 includes out-of-the-box cluster support
  4. 4. REDIS – Memory Management • Has no fixed Max Memory limit on the cache instance • By default uses the jemalloc memory allocator which cannot keep up with a high rate of allocations and purging • More objects put in, more memory is used • Certain loads could cause memory leaks at times
  5. 5. MEMCACHED- Memory Mgmt • Allocates one large chunk of memory. The max page size is 1MB • Uses its own slab-allocator and remember each slab-class has its own LRU • This means memory chunks get allocated only from their specific class even if there’s a free chunk in another slab-class • Internal fragmentation is low as it uses per-slab LRU algorithm • Suitable where memory usage has to be enforced • Consistent hashing is used which reduces key misses. • REDIS doesn’t match up when for this use case – LRU based, non-persistent
  6. 6. Slab Allocation • Frequent initialization and destruction of kernel objects can hamper performance. • When an object is destroyed the memory is not released. Instead it gets added to a list of available nodes • The memory gets reused when a similar type of object has to be initialized • Minimizes fragmentation by avoiding frequent allocation/deallocation • Ref : https://en.wikipedia.org/wiki/Slab_allocation
  7. 7. Where does REDIS make sense • Handles variety of formats : lists, sets, array • Working with sorted sets in memory. It beats memcached here • collating page clicks analytics data • displaying real-time leaderboard info • High speed data ingest • Message queuing • Session Storage
  8. 8. REDIS pros • Works better with a geographically distributed cache, say AWS zones • Pipelining helps in multiple operations on cached datasets at once • Stores data in a variety of formats : sets, lists, sorted sets, bitmaps, hashes, geospatial indices. Atomic ops on these is possible. Eg. Push new elem to list • Blocking reads – will wait till a write completes • Backs data to disk • Partitions data across multiple REDIS instances • Fine-tune cache contents by choosing from 6 eviction policies • Persistent by default, so restarts are better. No cache warmup is needed • Lua scripting
  9. 9. REDIS cons • SENTINEL which controls slave-master promotion is unstable. If it fails then failover from slave-master fails • Complex to configure and administer for monitoring, partitioning & balancing • Ref: http://www.bigdatalittlegeek.com/blog/2014/3/25/memcached-vs- redis
  10. 10. Where does MEMCACHED make sense • Database queries, reduce read load on databases • Page fragments • REST round trips
  11. 11. MEMCACHED pros and cons • PROS • Low complexity, easy to configure, simple to cluster since a hashing algo is used by the client to shard across the cluster • CONS • Is just an in-memory key-value store • Caches sharded by client can’t be distributed across AWS zones • Adding a member to the pool requires a client reconfigure and re-start • Eviction policy is LRU and sometimes the object being evicted is simply the same size as the new one http://www.bogotobogo.com/DevOps/Redis/Redis_vs_Memcached.php • Cache misses happen on a restart
  12. 12. MEMCACHED pros and cons • MEMCACHED is supposed to perform better when there are concurrent requests • Eviction policy is better implemented • Depends on: • Type of hardware,Types of data you store • Amount of get and set, App concurrency • Do you need data structure storage
  13. 13. A word on clustering Consistent hashing on Memcached is still a more robust model for graceful failure (at least if you are using it as a transient cache) than the Redis sharding. As nodes fall the cache keys automatically move to other servers. As long as you have a single server your cache still operates, albeit poorly. As opposed to redis where, to my understanding, if you lose master and slave for any hashgroup your cluster fails.
  14. 14. References • http://www.bigdatalittlegeek.com/blog/2014/3/25/memcached-vs-redis • http://www.bogotobogo.com/DevOps/Redis/Redis_vs_Memcached.php • http://blog.andolasoft.com/2014/02/memcached-vs-redis-which-one-to-pick-for-large-web-app.html • https://www.adayinthelifeof.nl/2011/02/06/memcache-internals/ • http://stackoverflow.com/questions/4188620/redis-and-memcache-or-just-redis?rq=1 • http://stackoverflow.com/questions/7888880/what-is-redis-and-what-do-i-use-it-for?rq=1 • http://stackoverflow.com/questions/10558465/memcached-vs-redis?rq=1 • http://stackoverflow.com/questions/23601622/if-redis-is-already-a-part-of-the-stack-why-is-memcached- still-used-alongside-r?rq=1 • http://stackoverflow.com/questions/10558465/memcached-vs-redis

×