Why is Redis better than Memcached?

What is Redis?

Redis is an in-memory storage of data structures. It is used as a database, a cache. It supports data structures such as strings, lists, sets, bitmaps, hyperlogs, geospatial indexes. It has built-in replication, supports Lua scripts, provides high availability with Redis Sentinel and automatic partitioning with Redis Cluster.

To achieve high performance Redis works with an in-memory dataset. Depending on how we use it, we have the option to either persist or dump the data to disk from time to time. Persistence can be turned off if we only need a feature-rich network cache.

Redis maps keys to value types. An important difference between Redis and other structured storage systems is that it supports not only strings but also abstract data types such as:

  • string sets
  • sorted string sets
  • hyperloglog
  • hash tables
  • geospatial data

Persistence – by default data is written to the file system at least every 2 seconds, with more options available if required. In the event of a total system failure with the default settings, only the data from the last few seconds would be lost.

Performance – When data persistence is not needed Redis enables performance compared to database systems. It runs as a single process and is single or dual threaded when rewriting AOF.

Clustering – The cluster specification implements a subset of Redis commands – all commands with a single key are available, operations with multiple keys are restricted to keys belonging to the same node and commands related to database selection operations are unavailable. The Redis cluster is capable of scaling up to 1000 nodes while achieving acceptable write security

Redis and Memcached

Redis and Memcached are both cache engines. They offer high performance and have many similarities but also have important differences. Memcached was designed with simplicity in mind, while Redis offers a rich set of features that make it effective for a wide range of applications. Redis is newer and more versatile and is almost always the best choice.

Below are some of the differences:

  • Memory usage – in redis, setting the maximum size is up to the user, it will not consume more than it needs to and memory that is no longer used will be released, which in the case of memcached is only possible if memcached is restarted.
  • Disk memory dump – redis does this by default and is highly configurable in this respect, whereas memcached needs additional tools for this.
  • Performance – this is often load-dependent and comparable between redis and memcached, but there are loads that memcached cannot handle, while memcached can.
  • Scaling – redis includes tools that allow us to get more of what memcached cannot.
  • Key/value pairs – memcached can store key/value pairs, where the value is limited to a string of 1MB, while in redis they can be up to 512 MB.
  • Data persistence – by default, redis persists data using a mechanism called snapshot. There are many configuration options to fine-tune the persistence.
  • Multiple data types – memcached has string limitations. Redis is a data structure server that can handle many different data types.
  • Pipelining – redis can cache several commands and execute them simultaneously. This allows even greater throughput for bulk imports or other activities that require multiple commands.

Redis has much more functionality and does everything that memcached does better. The advantage of redis can be seen in practically every aspect, thanks to it you get a lot of power and greater efficiency.

Test hosting with Redis for free

Each Gold package has its own dedicated Redis server

Test free of charge for 14 days. If necessary, we will migrate your data free of charge.

Other articles about Litespeed and Redis:

Is Litespeed faster than Apache?

LiteSpeed or Apache , what should I choose for my site?

How to activate Redis on Smarthost server?

Smarthost