If redis is already a part of the stack, why is Memcached still used alongside Redis?
Redis can do everything that memcached provides ( LRU cache, item expiry, and now clustering as well,(version 3.x or more, currently in beta) or by tools like twemproxy. The performance is similar too . Morever, Redis adds persistence due to which you need not do cache warming in case of a server restart.
Inspite of this, on studying stacks of large webscale companies like Instagram,Pinterest,Twitter etc, I found that they use both Memcached and Redis for different purposes, not using Redis for primary caching. The primary cache is still Memcached, and Redis is used for its data structures based logical caching.
My question is , as of 2014, why is memcached still worth the pain to be added as additional component into your stack, when you already have a Redis component which can do everything that memcached can ? What are the favorable points that incline the architects/engineers to still include memcached apart from already existing redis ?
-----
Answered by Salvatore Sanfilippo (aka antirez)
-----
The main reason I see today as an use-case for memcached over Redis is the superior memory efficiency you should be able to get with plain HTML fragments caching (or similar applications). If you need to store different fields of your objects in different memcached keys, then Redis hashes are going to be more memory efficient, but when you have a large number of key -> simple_string pairs, memcached should be able to give you more items per megabyte.
Other things which are good points about memcached:
- It is a very simple piece of code, so if you just need the functionality it provides, it is a reasonable alternative I guess, but I never used it in production.
- It is multi-threaded, so if you need to scale in a single-box setup, it is a good thing and you need to talk with just one instance.
I believe that Redis as a cache makes more and more sense as people move towards intelligent caching or when they try to preserve structure of the cached data via Redis data structures.
[...]
Your new post is loading...
Excellent detailed explanation of the difference between two quite similar memory stores, with talkative use case