Why Memecached is more popular than Redis for Rails cache store?

According to the rails documentation about ActiveSupport::Cache::MemCacheStore,

This is currently the most popular cache store for production websites

I prefer to use Redis as a queue for Sidekiq, and Memcached as a rails cache store.

But I’m still not sure what’s the big advantages of using Memcached over Redis for Rails cache storage. Maybe it’s because I’ve never actually scaled Memcached or Redis.

What do you think are the main reasons Memecached is more popular than Redis for Rails cache store?
Is it because of scalability and reliability, as mentioned in this article?

2 Likes

I have been known to use Redis for both cache and worker queue. The key is that they need to be different instances as they need different eviction policy.

For a cache store you want a “least recently used” policy. Specifically allkeys-lru. This will let you not deal with expiring content but any old cache just naturally is removed.

For a worker queue it really should be an error if you run out of space so you want the noeviction policy. This way if you try to insert a new job and are out of space it will fail rather than just silently removing old jobs.

Thanks @e_a, I’m also considering to use Redis for both cache and worker queue at the moment. So, It’s good to know the policies you mentioned.

Memcached exists since 2003, while Redis was created in 2009. This means memcached had 6 years to get adopted and developers to develop expertise with it. Since they both do the job, those who already know how to operate Memcached don’t see much reason to switch to redis. Same happens with sidekiq/resque.

Stick with Redis, since that’s what sidekiq uses, and then you don’t have to learn two very similar pieces of software.

Thanks @brenogazzola, That sounds like a pretty historical reason and makes sense to me!

So you don’t think there’s big advantages to using Memcached over Redis for Rails cache storage?

Has anyone experienced any differences between Memcached and Redis regarding scalability and reliability or anything else?

My experience is only with my own app (50-100RPS) where a cheap EC2 instance running redis can handle all our caching needs with ease, even when we have have dozens of sidekiq workers hammering it to fetch cached models/arrays.

So, both work, and the small differences between the two means, IMHO, it’s better to have just sidekiq for cache/job than memcached for cache and redis for jobs.

1 Like

You mean, better to have just redis?

Thanks for sharing your experience!

You mean, better to have just redis?

Ops, correct.

1 Like