Last Updated: September 09, 2019
· hafizbadrie

Simple and Short Test: Memcached and Redis

This is my first post in this web and I'd like to share my simple and short test between Memcached and Redis. The test was performed against single memcached server and also single redis server. This is the code that I used for the test:

This is the test result (in seconds)

The first test is fresh, that means Memcached is empty and Redis, as well. Next tests are not fresh, I used the latest state from the previous test.

Actually, I believed memcached is faster, in the first place. But I don't have any proof to support it. This test brings conclusion that Memcached is faster than Redis in both set and get processes. That means it's better for you to use memcached as your caching engine. Memcached and Redis are known for their advantage in distributed system. Therefore, next test should be testing against distributed Memcached and Redis servers.

That's all, folks!

2 Responses
Add your response


Redis and Memcached are not comparable. many application, specially such applications that requires extremely high scale, will actually use both Redis and Memcached.

Redis is single threaded and allows for atomic operations by design, it's a Key/Value store with a very complex set of datatypes being supported and above all that, data in Redis can be persisted and hence still present across restarts.

Memcached is much simpler (and powerful exactly for that) and is the perfect solution for simple Key to Text Blocks, it's ability to compress content allows for efficient storage of large quantities of large text blocks (such as full HTML pages), data is stored in RAM only and hence, perishable.

So, as always, plain benchmarking is in many ways a little miss leading.

over 1 year ago ·

Hi avnerner,
I'm fully aware to what you're saying. Actually, my point is to give people an understanding not to use redis as a cache, though it has a similar feature with memcache: data expiration. I saw many discussions about comparing redis and memcached as a cache store and through this test I was expecting to give that kind of discussions a conclusion.

over 1 year ago ·