DEV Community

Nic
Nic

Posted on • Originally published at coderscat.com on

Redis Vs. Memcached

Redis and Memcached are both popular in-memory data storage systems.

Aws has a comparison for them. We can see from the table, Redis beats Memcached almost in every aspect:

CAPTURE-2020_04_08_redis-vs-memcached.org_20200408_233953.png

Performance

Memcached has better performance for big data, such as data of 100k or above.

Redis is single-threaded and will beat Memcached on small data reading and writing.

Data types

There is only string type in Memcached.

Redis supports many kinds of data types, including string, set, list, hash, sorted set, geo, bitmap.

These data types are useful for different scenarios and needs.

The largest data size can only be 1 MB in Memcached, while we can use the maximum of 1GB in Redis.

Persistence

Memcached does not have a mechanism for persistence.

Redis supports AOF(Append Only File) and RDB persistence for persistence. This is very important for many applications. We could use Redis as a NoSQL database.

Scaling

Memcached itself does not support distributed mode. We need to adapt distributed algorithms such as Consistent Hash for distributed storage of Memcached.

Redis provides builtin support for clustering and is bundled with a high availability tool called redis-sentinel. Redis Cluster supports a maximum of 4,096 nodes.

Conclusion

Redis could do everything that Memcached targeted to.

Choose to use Redis whenever possible.

The post Redis Vs. Memcached appeared first on Coder's Cat.

Top comments (0)