Redis vs Memcached- Review, Features and Comparison

 In Email Infrastructure

Redis or Memcached is the common question that arises these days in technical discussions. The comparison between Redis and Memcached usually comes up when one needs to look for performance improvement out of a modern and data-based driven application. And when performance is considered, caching comes prior and thus Memcached or Redis are first places to look for. Well, both Redis and Memcached are equally popular, open-source and in-memory data stores application. They both offer great performance and are easy to use but definitely there are some differences that will make you choose any one of the engine.

Redis, on one hand, offers an ironic set of features making it efficient for wide range of uses whereas Memcached is known for its simplicity. Also Redis is little new and more versatile but one can only choose after knowing their requirements and what engine has to offer to the user. And for this in this guide you can find your answers to Redis vs. Memcached- which gives better performance, what are its pros and cons, feature similarities and which one to choose.

Designing the Caching system

While designing any caching system one must consider the following points:

  • Read/write speed.
  • Memory usage.
  • Disk I/O dumping.

Once you have approved of this design then it will be easy for you to compare and hence give your vote to one of the engine.

What is Redis?

Redis basically is known as a data structure server. Also known as “Memcached on steroids. This one is open-source, in-memory, networked web application. It stores keys with optional durability. The development of Redis was sponsored by Pivotal Software since May 2013; earlier it was sponsored by VMware. Redis was ranked as the most popular key-value store. The name Redis stands for REmote DIctionary Server since it refers to the data structure server. Its keys contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperlogs.

What is Memcached?

Memcached is an open source and distributed memory object caching system. It is known to alleviate the database load to speed up the dynamic Web applications. Memcached was originally developed by Brad Fitzpatrick in 2003 for the Live Journal website. The system caches data in memory/RAM and minimizes the frequency through which an external database or API (application program interface) is accessed. Memcached has been rewritten in C, originally implementation was in Perl and then put in the public domain for optimization.

Why Memcached?

When caching relatively small and static data, Memcached is more preferable. And so when you are working with HTML ode fragments then Memcached is more preferable. The internal memory of this application consumes the least memory resources for metadata, and it is thus more efficient than its contemporary. Even in the simplest of uses, internal memory management is effective.

However, when dynamic data size comes into play the efficiency of the memory management system of Memcached diminishes. At such point, the memory of the application can also become fragmented. Also, as huge data sets involve serialized data, the space required to store the information also increases. And so if you are working with Memcached then there are chances that your data will be lost as the size of the same increases, and rebuilding the cache, on the other hand, can be an expensive process.

When compared to the other such applications in the market like Redis, another scenario comes into action. And so when we talk in terms of scaling, Memcached has an advantage above Redis. As Memcached is multithreaded, using the more computational resources you can easily scale up. On the other hand, Redis being single-threaded, via clustering can scale up horizontally. Also the loss of data in the latter is zero. Even though the process of clustering is an active scaling solution, it very complex when compared to the other methods in both set up and operation. Also Memcached does not support replication.

High traffic websites can be handled well with Memcached. With this system you can read a lot of information simultaneously, and in turn get a great response time. On the other hand Redis handles high traffic on read, and at the same time also handles heavy writes.

Why Redis?

Redis open up a whole new world of possibilities with its five primary data structures. The application developers can choose from these structures providing features like manipulation of the cached data along with intelligent caching. The data structures of Redis (data is stored in a variety of formats: array, lists, sets and sorted sets) as a cache gives greater efficiency and a lot of power overall to the developer.

In this memory caching system, the mechanism of data eviction is employed that deletes the old data to makes more room for the new data. On the other hand the memory eviction system of Memcached is a little different. It employs the Least Recently Used algorithm which randomly evicts the old data that is comparable to the size of the new data.

There are six different eviction policies from which you can choose that allows the fine-grained control over eviction. Both lazy and active eviction is supported by Redis, where the data is eliminated only when there is a need of space. On the other hand, Memcached provides only lazy eviction.

Redis vs Memcached- Features Comparison

There are several similarities between Memcached and Redis along with the specific differences that each engine offers. Both the system give enough point of comparison between them that can be analyzed. For instance, Memcached is preferred while caching of relatively small and static data. Also internal memory management is more efficient because it consumes less memory resources for metadata. On the other hand, Redis comprises of five primary data structures to choose from, that introduces to the world a possibilities to the application developer through intelligent caching and manipulation of data. Redis is preferred over Memcached due to its data structures giving lot of power.

Let us discuss the points that are in the support of above comparisons.

Redis vs. Memcached for caching

Let us begin with the similarities of both. Memcached and Redis both serve the purpose of in-memory and key-value data stores. Although Redis proves to be more accurate as a data structure store. Both Memcached and Redis are from NoSQL family of data management solutions. They keep all the data in RAM, which is useful in terms of a caching layer. In terms of performance, they are remarkable with identical characteristics and metrics.

Both of them are used by many companies and mission-critical production settings and are supported by client libraries in all programming language, and is a part of multitude of packages for developers.

Redis vs. Memcached- Data Types Supported

Memcached only supports data records of the simple key-value structure whereas Redis supports more data types. The data types of Redis include String, Hash, List, Set and Sorted Set. In addition, Redis also uses a redisObject within and represents wholly the keys and values.

Redis vs Memcached- Memory management scheme

The unique thing about Redis is that not all its data storage occurs in memory which becomes a major difference between both. In case of full physical memory, Redis may swap values no longer in use. It catches all the key information. These values are then made persistent into the disk and erases from memory. This feature of Redis maintains data of a size bigger than its machine memory capacity.

The memory management efficiency is a key for the system’s performance. Both Redis and Memcached are able to adopt their self-designed memory management mechanisms, but the methods of implementation may vary a lot. Memcached uses the Slab Allocation mechanism for memory management by default. This facilitates the storage of all key-value data in the Slab Allocation system.

Thus Memcached has high memory management efficiency not causing memory fragments. But its major defect is that it causes space waste.

Redis vs Memcached- Support of Data Persistence

Although both are a memory-based store, Redis is a major support for memory data persistence. It provides two major persistence policies, RDB snapshot and AOF log. Whereas Memcached does not supports the data persistence operation.

Redis vs Memcached- Cluster Management

Although Redis supports data persistence but Memcached is for a full-memory data buffering system. Memcached does not supports the distributed mode and is achieved by the distributed storage on the client side. While, Redis prefers distributed storage on the server side. Although its latest version, Redis Cluster supports distributed storage.

Sub-millisecond latency

The sub-millisecond latency/response time is supported by both Redis and Memcached. So as the data is stored in-memory, the data can be read more quickly than the databases based on disk.

Developer ease of use

Both Redis and Memcached caching system are easy to use and involves easy integration with minimal amount of code.

Data partitioning

You can distribute the data among multiple nodes on both Redis and Memcached. This is important as it allows scaling and better handling of the data.

Support for a broad set of programming languages

The developers get various open-source clients while working with Memcached and Redis. Java, PHP, Python, C, C++, JavaScript, Ruby, Node.js, are some of the supported languages.

My Concluding Remarks

On the basis of above facts, one could easily conclude that both Memcached and Redis are equally popular. Not only they are simple but are effective as well. Therefore getting started to work on either Redis or Memcached is easy work for the developer. The setup of both takes only a few minutes. Therefore a small investment in these engines provides a dynamic impact on the performance and huge benefit. Although Redis can be the obvious solution and better option but Memcached is also useful in various ways.

Know Why Pepipost picks Redis over Memcached everytime!

Found This Blog Interesting Please Rate This Blog 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Recent Posts

Leave a Comment

We are always looking for fresh talent to contribute to our blog. If you have a knack for writing and a passion for email marketing, we would love to have your post on our Guest Blog .

Submit a Guest Post
Pepi thinking

Start typing and press Enter to search

Thank you for your details!

Fill out your information below, and we will send you a PepiAlert, that will describe your domain’s email deliverability situation. Please note that your email address must match the domain, or the domain must be owned by the company matching the email address. We have the right to refuse the request, if we can’t verify the information.

*All fields are required



%d bloggers like this: