Redis vs. Memcached – 2021 Comparison
Tags: redis, memcached, database, comparison
Published: 2021-05-07 23:25:11

---
title: Redis vs. Memcached – 2021 Comparison
published: true
description: In this 2021 comparison of Redis and Memcached, we compare the different features and functions as well as their performance. See who comes out on top!
tags: redis, memcached, database, comparison
cover_image: https://scalegrid.io/blog/wp-content/uploads/2021/04/Redis-vs-Memcached-2021-Comparison-ScaleGrid-Blog.jpg
---
<link rel="canonical" href="https://scalegrid.io/blog/redis-vs-memcached-2021-comparison/" />
<p style="text-align: justify;"><a style="color:#24890d" href="https://redis.io/">Redis</a> stands for <b>RE</b>mote <b>DI</b>ctionary <b>S</b>erver, created in 2009 by <a style="color:#24890d" href="https://redislabs.com/blog/thank-you-salvatore-sanfilippo/">Salvatore Sanfilippo</a>. <a style="color:#24890d" href="https://memcached.org/">Memcached</a>, on the other hand, was created in 2003 by <a style="color:#24890d" href="https://en.wikipedia.org/wiki/Brad_Fitzpatrick">Brad Fitzpatrick</a>. Both Redis and Memcached are:</p>

<ul>
	<li>NoSQL in-memory data structures</li>
	<li>Written in C</li>
	<li>Open source</li>
	<li>Used to speed up applications</li>
	<li>Support sub-millisecond latency</li>
</ul>
<p style="text-align: justify;">In 2014, Salvatore wrote an excellent <a style="color:#24890d" href="https://stackoverflow.com/a/23650189/2767333">StackOverflow post</a> on when it makes more sense to use Memcached than Redis. In this post, we provide a current and detailed comparison between Redis and Memcached so that you can make an informed choice about their use in your application.</p>
<h2>Infographic</h2>
This post has been condensed down into an infographic. With this infographic you can easily visualize the results of this comparison to see which one comes out on top in different scenarios. Click the image below to see the full infographic. If you want to read the comparison in text format, <a style="color:#24890d" href="#start">click here</a>.
<a href="https://scalegrid.io/blog/redis-vs-memcached-2021-comparison/"><img width="100%" height="auto" src="https://scalegrid.io/blog/wp-content/uploads/2021/05/Redis-vs-Memcached-Infographic-Preview-ScaleGrid-Blog.jpg" alt="Redis vs Memcached Infographic"/></a>

<h2><a id="start"></a>Documentation</h2>
<p style="text-align: justify;">To start off, Redis is much more comprehensively documented than Memcached. This makes it easier to learn, administer and use.</p>

<h2>Database Model</h2>
<p style="text-align: justify;">Redis is primarily a key value store. While keys are binary strings, the advantage with Redis is that the value is not limited to only binary strings. They can be a variety of data structures which enable storing of complex objects and provide a rich set of operations over them. Redis also provides for extensibility via Redis modules. Redis modules are extensions that provide for additional data structures and features not available within the core feature set. Here’s an sample of few features that are now available as modules:</p>

<ul>
	<li>Document Store</li>
	<li>Graph DBMS</li>
	<li>Search Engine</li>
	<li>Time Series DBMS</li>
</ul>
<p style="text-align: justify;">Memcached is a plain key value store which only supports binary strings as value.</p>

<h2>Data Structures</h2>
<p style="text-align: justify;">As mentioned above, Redis offers multiple data structure types allowing it to be extremely flexible to use, including Strings, <a style="color:#24890d" href="https://scalegrid.io/blog/introduction-to-redis-data-structures-hashes/">Hashes</a>, Lists, <a style="color:#24890d" href="https://scalegrid.io/blog/introduction-to-redis-data-structures-sets/">Sets</a>, <a style="color:#24890d" href="https://scalegrid.io/blog/introduction-to-redis-data-structures-sorted-sets/">Sorted Sets</a>, <a style="color:#24890d" href="https://scalegrid.io/blog/introduction-to-redis-data-structure-bitmaps/">Bitmaps</a>, Bitfields, HyperLogLog, Geospatial indexes, and Streams. You can learn more about these in this <a style="color:#24890d" href="https://scalegrid.io/blog/top-redis-use-cases-by-core-data-structure-types/">Top Redis Use Cases by Core Data Structure Types</a> article.</p>


<a style="color:#24890d" href="https://redislabs.com/wp-content/uploads/2020/06/key-value-data-stores-2-v2.png"><img width="100%" src="https://redislabs.com/wp-content/uploads/2020/06/key-value-data-stores-2-v2.png"></a>
<p style="font-size:10px;">Image source: <a style="color:#24890d" href="https://redislabs.com/redis-enterprise/data-structures/">https://redislabs.com/redis-enterprise/data-structures/</a></p>
<p style="text-align: justify;">Memcached only supports plain binary strings which are great for read-only data, so if you don't need all the bells and whistles of Redis, Memcached is a simpler database for you to use.</p>

<h2>Database Rank &amp; Popularity</h2>
<p style="text-align: justify;">The greater popularity of a database results in a larger community of users, more discussions and user-generated tutorials, and more help and support through third-party tools such as <a style="color:#24890d" href="https://scalegrid.io/redis/hosting-comparison.html">DBaaS platforms</a> and <a style="color:#24890d" href="https://scalegrid.io/blog/the-top-6-free-redis-memory-analysis-tools/">analysis tools</a> to help optimize your deployments.</p>
<p style="text-align: justify;">Redis is the 8th most popular database in the world as of February 2021, according to <a style="color:#24890d" href="https://db-engines.com/en/ranking">DB-Engines</a> because of its simplicity, rich data structures, and great documentation. Memcached is currently ranked as the 28th most popular database. When Redis and Memcached are ranked with respect to key-value database models, Redis stands in 1st and Memcached comes 4th. However, if you are looking only for an open-source key-value database, or one that can be deployed on-premise, <a style="color:#24890d" href="https://db-engines.com/en/ranking/key-value+store">Memcached comes in 2nd</a> as both Amazon DynamoDB and Microsoft Azure Cosmos DB are both commercial databases that can only be deployed in the cloud.</p>
<a href="https://scalegrid.io/blog/redis-vs-memcached-2021-comparison/"><img width="100%" src="https://scalegrid.io/blog/wp-content/uploads/2021/04/DB-Engines-Ranking-Key-Value-Store.png" alt="DB-Engines-Ranking-Key-Value-Store" /></a>
<h2>Architecture</h2>
<p style="text-align: justify;">Redis and Memcached both follow <b>client-server </b>architecture. Clients populate the data in the server in the form of key-value.</p>
<p style="text-align: justify;">Redis is single threaded where on the other hand Memcached has a multithreaded architecture. Memcached scales better on a system with more cores that can handle more operations if compute capacity is scaled. However, more than one Redis instance can be initiated on the same system to utilize additional cores.</p>

<h2>Ease of Use</h2>
<p style="text-align: justify;">As explained above in the Database model section, Redis, being a multi-model database, can be used with any type of data model. In Redis, it is easy to write code as it simplifies complex tasks. Redis has <a style="color:#24890d" href="https://redis.io/topics/data-types-intro">advanced data structures</a> and is not limited to simple string values. For instance, if your application stores data in sets and you want to keep track of sets in a list you can do this easily in Redis. A similar task on Memcached is not possible. But there are other ways to do the same tasks that will require more lines of code.</p>
<p style="text-align: justify;">Memcached, on the other hand, only stores plain string values. So, the application is left to deal with the data structure complexity.</p>

<h2>Data Partitioning</h2>
<p style="text-align: justify;">Redis supports <a style="color:#24890d" href="https://redis.io/topics/partitioning">partitioning</a> of data across multiple node instances. <a style="color:#24890d" href="https://stackshare.io/redis">Current users</a> of Redis leverage different techniques like range partitioning, hash partitioning, and consistent hashing for data partitioning. In Redis, data partitioning can be implemented in three different ways:</p>

<ul>
	<li>Client-side partitioning</li>
	<li>Proxy-assisted partitioning (example: <a style="color:#24890d" href="https://github.com/twitter/twemproxy">twemproxy</a>)</li>
	<li>Server-side partitioning with query routing within the cluster nodes</li>
</ul>
<p style="text-align: justify;">Memcached also supports data partitioning across multiple nodes, and <a style="color:#24890d" href="https://docs.oracle.com/en-us/iaas/Content/Resources/Assets/whitepapers/deploying-memcached-and-redis-on-oci.pdf">consistent hashing</a> is a recommended approach to ensure the traffic load is evenly distributed.</p>
<h2>Supported Languages</h2>
<p style="text-align: justify;">Redis supports almost all of the most used programming <a style="color:#24890d" href="https://db-engines.com/en/system/Memcached%3BRedis">languages</a>, from high-level to low-level languages. Memcached however supports less number of languages compared to Redis, but does support all the popular languages.</p>


<h4>Memcached</h4>
<ul style="column-count: 4;">
	<li>.Net</li>
	<li>C</li>
	<li>C++</li>
	<li>ColdFusion</li>
	<li>Erlang</li>
	<li>Java</li>
	<li>Lisp</li>
	<li>Lua</li>
	<li>OCaml</li>
	<li>Perl</li>
	<li>PHP</li>
	<li>Python</li>
	<li>Ruby</li>
</ul>
<h4>Redis</h4>
<ul style="column-count: 4;">
	<li>C</li>
	<li>C#</li>
	<li>C++</li>
	<li>Clojure</li>
	<li>Crystal</li>
	<li>D</li>
	<li>Dart</li>
	<li>Elixir</li>
	<li>Erlang</li>
	<li>Fancy</li>
	<li>Go</li>
	<li>Haskell</li>
	<li>Haxe</li>
	<li>Java</li>
	<li>JavaScript (Node.js)</li>
	<li>Lisp</li>
	<li>Lua</li>
	<li>MatLab</li>
	<li>Objective-C</li>
	<li>OCaml</li>
	<li>Pascal</li>
	<li>Perl</li>
	<li>PHP</li>
	<li>Prolog</li>
	<li>Pure Data</li>
	<li>Python</li>
	<li>R</li>
	<li>Rebol</li>
	<li>Ruby</li>
	<li>Rust</li>
	<li>Scala</li>
	<li>Scheme</li>
	<li>Smalltalk</li>
	<li>Swift</li>
	<li>Tcl</li>
	<li>Visual Basic</li>
</ul>
&nbsp;
<h2>Transactions</h2>
<p style="text-align: justify;"><a style="color:#24890d" href="https://redis.io/topics/transactions">Redis "transactions"</a> are executed with the three below guarantees:</p>

<ul>
	<li>Transactions are serialized and executed sequentially</li>
	<li>Either all of the commands, or none, are processed (atomic transactions)</li>
	<li>Optimistic locking offers an extra guarantee using check-and-set</li>
</ul>
<p style="text-align: justify;">Redis makes sure that all only one command from one client machine is executed at once. All the commands in the transactions are executed when the “EXEC” command is called to ensure the atomicity.</p>
<p style="text-align: justify;">Memcached, on the other hand, does not provide transaction management.</p>

<h2>Replication</h2>
<p style="text-align: justify;">Redis offers a simple leader-follower (master-slave) <a style="color:#24890d" href="https://redis.io/topics/replication">replication</a> that creates exact copies of the master instances, with these features:</p>

<ul>
	<li>The master keeps on sending data commands to the slave as long as they are connected.</li>
	<li>If the connection breaks, the slave will follow partial resynchronization only copying the data that was missed during disconnection.</li>
	<li>If partial resynchronization is not possible, then it will try a full resynchronization.</li>
</ul>
<p style="text-align: justify;">You can also leverage the high availability features, <a style="color:#24890d" href="https://scalegrid.io/blog/high-availability-with-redis-sentinels-connecting-to-redis-masterslave-sets/">Redis Sentinels</a> or <a style="color:#24890d" href="https://scalegrid.io/blog/?s=redis+cluster">Redis Cluster</a>, for advanced failover protection.</p>
<p style="text-align: justify;">Native Memcached does not support replication, but you can use <a style="color:#24890d" href="http://repcached.lab.klab.org/">Repcached</a>, a free open source patch to achieve high availability for your deployment. It offers multi master replication, asynchronous data replication, and supports all Memcached commands.</p>

<h2>Snapshots/Persistence</h2>
<p style="text-align: justify;">Snapshots are simply a read-only view of your database as it was at a certain point in time. Redis supports snapshots, and by default, Redis saves snapshots of the dataset on disk in a binary file called dump.rdb. You can manually call a snapshot, or customize the frequency or change threshold for running the operation.</p>
<p style="text-align: justify;">Here are the two <a style="color:#24890d" href="https://redis.io/topics/persistence">persistence</a> options Redis supports:</p>

<ul>
	<li>RDB persistence</li>
	<li>AOF persistence</li>
</ul>
<p style="text-align: justify;">RDB stands for “Redis Database Backup”. It is a compact, point-in-time snapshot of the database at a specific time. It takes up less space, maximizes Redis performance, and is good for disaster recovery.</p>
<p style="text-align: justify;">AOF stands for “Append Only File”. AOF keeps track of all the commands that are executed, and in a disastrous situation, it re-execute the commands to get the data back. This method takes more space as all the commands are executed again, and is not a very durable method of snapshotting.</p>
<p style="text-align: justify;">Memcached on the other hand does not support on disk persistence.</p>

<h2>Server-Side Scripts</h2>
<p style="text-align: justify;">Lua is the embedded scripting language for your Redis server, available as of version 2.6, which lets you perform operations inside Redis to simplify your code and increase performance. The two main functions used to evaluate scripts using the Lua interpreter are:</p>

<ul>
	<li>EVAL</li>
	<li>EVALSHA</li>
</ul>
<p style="text-align: justify;">When Lua script is being executed all other requests are blocked as shown in the figure below.</p>
<p style="text-align: justify;"><a href="https://scalegrid.io/blog/redis-transactions-long-running-lua-scripts/"><img class="alignnone size-full wp-image-5618" src="https://scalegrid.io/blog/wp-content/uploads/2020/06/Redis-Lua-Scripts-Diagram.jpg" alt="Redis Lua Scripts Diagram - ScaleGrid Blog" width="100%" height="auto"></a></p>
<p style="text-align: justify;">Redis also includes <a style="color:#24890d" href="https://redis.io/topics/ldb">Lua scripts debugger</a> in version 3.2 which makes writing complex scripts easier and helps in boosting performance.</p>
<p style="text-align: justify;">Memcached does not support any server-side scripting.</p>

<h2>Scalability</h2>
<p style="text-align: justify;">There are two techniques to horizontally scale your Redis database:</p>

<ul>
	<li>Adding shards in Redis Clusters</li>
	<li>Adding nodes to a Redis HA (master/replica) setup</li>
</ul>
<p style="text-align: justify;">You can also vertically scale your Redis setup when you need more memory or compute. It can be done without downtime if you have a HA setup or you use Redis Cluster technology.</p>
<p style="text-align: justify;">The Memcached server doesn’t provide a mechanism to distribute data across nodes (sharding). So, in Memcached, horizontal <a style="color:#24890d" href="http://pages.cs.wisc.edu/~vijayc/papers/memcached.pdf">scalability</a> is as simple as adding more nodes - the problem of partitioning your data into different shards will have to be done on the application/client level. There are some open source tools that can help you with this.</p>

<h2>Communication Protocol</h2>
<p style="text-align: justify;">Redis uses TCP as a network protocol and does not support UDP.</p>
<p style="text-align: justify;">Memcached supports both the TCP and UDP <a style="color:#24890d" href="https://www.it.iitb.ac.in/frg/wiki/images/1/13/Memcache_detailed_report.pdf">communication protocols</a>. Data is sent to the Memcached server in two forms:</p>

<ul>
	<li>Text lines: Send commands and receive responses from the server.</li>
	<li>Unstructured data: Receive or send value information for a given key, and data is returned in the same format provided.</li>
</ul>
<h2>Supported Cache Eviction Policies</h2>
<p style="text-align: justify;">Redis supports different types of <a style="color:#24890d" href="https://docs.redislabs.com/latest/rs/administering/database-operations/eviction-policy/">eviction policies</a>. Let's take a look at some.</p>

<ul>
	<li><b>noeviction: </b>In “noeviction” an error is returned when memory reaches it bound.</li>
</ul>
<ul>
	<li><b>allkeys-lru: </b>Lru stands for “least recent used”. This policy removes the least recently used data.</li>
</ul>
<ul>
	<li><b>allkeys-lfu: </b>Lfu stands for “least frequently used”. This policy removes the least frequently used data.</li>
</ul>
<ul>
	<li><b>allkeys-random: </b>This policy removes the data randomly.</li>
</ul>
<ul>
	<li><b>volatile-lru: </b>Volatile data is with expiration data set. This policy removes the least recently used volatile data.</li>
</ul>
<ul>
	<li><b>volatile-lfu: </b>Volatile data is with expiration data set. This policy removes the least frequently used volatile data.</li>
</ul>
<ul>
	<li><b>volatile-random: </b>This policy removes the volatile data randomly.</li>
</ul>
<ul>
	<li><b>volatile-ttl: </b>“TTL” stands for time to live. This policy removes the data that have the shortest time to live.</li>
</ul>
<p style="text-align: justify;"><a style="color:#24890d" href="https://github.com/memcached/memcached/wiki/UserInternals">Memcached</a> uses <a style="color:#24890d" href="https://github.com/memcached/memcached/blob/master/doc/new_lru.txt">LRU algorithm</a> to evict data when space is required. It first searches for the already expired data to delete if expired data is not available the <a style="color:#24890d" href="https://github.com/memcached/memcached/blob/master/doc/new_lru.txt">LRU algorithm</a> is used.</p>

<h2>Publish &amp; Subscribe Messaging</h2>
<p style="text-align: justify;">Redis supports <a style="color:#24890d" href="https://redis.io/topics/pubsub">Pub/Sub messaging</a> (publish and subscribe). There are three commands that are used for this purpose.</p>
<p style="text-align: justify;">The client uses:</p>

<ul>
	<li>Subscribe</li>
	<li>Unsubscribe</li>
</ul>
<p style="text-align: justify;">Subscribe and unsubscribe are used to get messages from a specific channel.</p>
<p style="text-align: justify;">The server uses:</p>

<ul>
	<li>Publish</li>
</ul>
<p style="text-align: justify;">The “publish” is used to push data to the clients.</p>
<p style="text-align: justify;">Memcached does not support publish and subscribe messaging.</p>

<h2>Streams Support</h2>
<p style="text-align: justify;">Redis supports Kafka-like streams with 5.0 or higher version using a new data structure “<a style="color:#24890d" href="https://redis.io/topics/streams-intro">Redis Streams</a>”. Redis Streams has the concept of consumer groups, like <a style="color:#24890d" href="https://kafka.apache.org/">Apache Kafka</a>, that lets client applications consume messages in a distributed fashion, making it easy to scale and create highly available systems.</p>
<p style="text-align: justify;">Memcached does not offer native support for Streams, but there are open source library tools like <a style="color:#24890d" href="https://www.madewithtea.com/posts/kafcache-memcached-and-kafka-streams">Kafcache</a> for stream processing at low latency.</p>

<h2>Geospatial Support</h2>
<p style="text-align: justify;">Redis has a data structure called <a style="color:#24890d" href="https://redis.io/commands/geoadd">Geospatial indexes</a> that stores the longitude and latitude data of a location. You can perform different operations on the geospatial data, like calculating the distance between two points or finding nearby places.</p>
<p style="text-align: justify;">Memcached does not have any special data structures to handle geospatial data.</p>

<h2>Performance</h2>
<p style="text-align: justify;">A performance comparison between in-memory key-value data stores is more of an intellectual exercise than of any practical importance - unless you are deploying systems at such scale that this becomes interesting as a cost-saving measure. This is because such stores are IO bound and usually the network latency might play a bigger role in application perceived latency than the database latency.</p>
A more practical performance aspect is storage efficiency - how much data can be packed in the same amount of memory. Even here, the internal data structures used by Redis vary based on the data size. So any discussion on performance between these databases should be taken with a pinch of salt.
<p style="text-align: justify;">Let’s take a look at some comparisons shown in a 2016 research <a style="color:#24890d" href="https://www.researchgate.net/publication/304780144_A_performance_evaluation_of_in-memory_databases">paper</a>. In this paper, the authors experiment the widely used in-memory databases to measure their performance in terms of:</p>

<ol>
	<li>The time taken to complete operations.</li>
	<li>How efficiently they use memory during operations.</li>
</ol>
<p style="text-align: justify;">Database versions used in the paper:</p>

<table width="100%">
<tbody>
<tr>
<th style="background-color: #def5fe; padding: 10px;" width="50%">Database</th>
<th style="background-color: #273039; padding: 10px; color: #fff;" width="50%">Version</th>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Redis</td>
<td style="border: 1px solid #eee; padding: 10px;">3.0.7</td>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Memcached</td>
<td style="border: 1px solid #eee; padding: 10px;">1.4.14</td>
</tr>
</tbody>
</table>
<h2>Write Operation</h2>
<p style="text-align: justify;">While writing data, as you can see, in the table below Memcached shows exceptional speed even after the number of records moves up to million.</p>
<b>The calculated time to write key-value pairs (ms)</b>
<table width="100%">
<tbody>
<tr>
<th style="padding: 10px;" width="20%"></th>
<th colspan="4" style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="80%">Number of records</th>
</tr>
<tr>
<td style="border: 1px solid #eee;background-color: #def5fe; padding: 10px;" width="15%"><b>Database</b></td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">1,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">10,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">100,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">1,000,000</td>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Redis</td>
<td style="border: 1px solid #eee; padding: 10px;">34</td>
<td style="border: 1px solid #eee; padding: 10px;">214</td>
<td style="border: 1px solid #eee; padding: 10px;">1,666</td>
<td style="border: 1px solid #eee; padding: 10px;">14,638</td>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Memcached</td>
<td style="border: 1px solid #eee; padding: 10px;">23</td>
<td style="border: 1px solid #eee; padding: 10px;">100</td>
<td style="border: 1px solid #eee; padding: 10px;">276</td>
<td style="border: 1px solid #eee; padding: 10px;">2,813</td>
</tr>
</tbody>
</table>
<h2>Read Operation</h2>
<p style="text-align: justify;">Reading data stays almost consistent in Redis even for a million records but in Memcached as the number of records go up the time also increases a little bit.</p>
<b>The elapsed time to read value corresponding to a given key per database (ms)</b>
<table width="100%">
<tbody>
<tr>
<th style="padding: 10px;" width="20%"></th>
<th colspan="4" style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="80%">Number of records</th>
</tr>
<tr>
<td style="border: 1px solid #eee;background-color: #def5fe; padding: 10px;" width="15%"><b>Database</b></td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">1,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">10,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">100,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">1,000,000</td>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Redis</td>
<td style="border: 1px solid #eee; padding: 10px;">8</td>
<td style="border: 1px solid #eee; padding: 10px;">6</td>
<td style="border: 1px solid #eee; padding: 10px;">8</td>
<td style="border: 1px solid #eee; padding: 10px;">8</td>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Memcached</td>
<td style="border: 1px solid #eee; padding: 10px;">9</td>
<td style="border: 1px solid #eee; padding: 10px;">14</td>
<td style="border: 1px solid #eee; padding: 10px;">14</td>
<td style="border: 1px solid #eee; padding: 10px;">30</td>
</tr>
</tbody>
</table>
&nbsp;
<h2>Memory Use</h2>
<p style="text-align: justify;">While discussing memory usage, Redis is always the best as you can see in the <a style="color:#24890d" href="https://www.researchgate.net/publication/304780144_A_performance_evaluation_of_in-memory_databases">results</a>.</p>
<b>Memory usages of in-memory databases for write operation (MB)</b>
<table width="100%">
<tbody>
<tr>
<th style="padding: 10px;" width="20%"></th>
<th colspan="4" style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="80%">Number of records</th>
</tr>
<tr>
<td style="border: 1px solid #eee;background-color: #def5fe; padding: 10px;" width="15%"><b>Database</b></td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">1,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">10,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">100,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">1,000,000</td>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Redis</td>
<td style="border: 1px solid #eee; padding: 10px;">2.5</td>
<td style="border: 1px solid #eee; padding: 10px;">3.8</td>
<td style="border: 1px solid #eee; padding: 10px;">4.3</td>
<td style="border: 1px solid #eee; padding: 10px;">62.7</td>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Memcached</td>
<td style="border: 1px solid #eee; padding: 10px;">5.3</td>
<td style="border: 1px solid #eee; padding: 10px;">27.2</td>
<td style="border: 1px solid #eee; padding: 10px;">211</td>
<td style="border: 1px solid #eee; padding: 10px;">264.9</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;">As you can see Redis is better than Memcached.</p>
<b>Memory usages of in-memory databases for delete operation (MB)</b>
<table width="100%">
<tbody>
<tr>
<th style="padding: 10px;" width="20%"></th>
<th colspan="4" style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="80%">Number of records</th>
</tr>
<tr>
<td style="border: 1px solid #eee;background-color: #def5fe; padding: 10px;" width="15%"><b>Database</b></td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">1,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">10,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">100,000</td>
<td style="border: 1px solid #eee;background-color: #273039; padding: 10px; color: #fff;" width="15%">1,000,000</td>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Redis</td>
<td style="border: 1px solid #eee; padding: 10px;">0</td>
<td style="border: 1px solid #eee; padding: 10px;">0</td>
<td style="border: 1px solid #eee; padding: 10px;">0</td>
<td style="border: 1px solid #eee; padding: 10px;">0</td>
</tr>
<tr>
<td style="border: 1px solid #eee; padding: 10px;">Memcached</td>
<td style="border: 1px solid #eee; padding: 10px;">2.2</td>
<td style="border: 1px solid #eee; padding: 10px;">2.1</td>
<td style="border: 1px solid #eee; padding: 10px;">2.2</td>
<td style="border: 1px solid #eee; padding: 10px;">2.2</td>
</tr>
</tbody>
</table>

<h2>Transport Layer Security (TLS) Support</h2>
<p style="text-align: justify;">Redis has native TLS support starting Redis 6.0. Earlier versions of Redis recommended the use of stunnel for providing TLS support.</p>
<p style="text-align: justify;">Memcached 1.5.13 and above versions support authentication and encryption via <a style="color:#24890d" href="https://github.com/memcached/memcached/wiki/TLS">TLS</a>. This feature is still in <a style="color:#24890d" href="https://github.com/memcached/memcached/wiki/TLS">experimental stages</a>.</p>

<h2>Authentication</h2>
<p style="text-align: justify;">Up to Redis 5.x, Redis only supported a simple password based authentication. This password was stored in plaintext on the server. Redis in version 6.0 onwards supports a fully featured <a style="color:#24890d" href="https://redis.io/topics/acl">ACL</a>.</p>
<p style="text-align: justify;">Memcached version 1.4.3 and greater has <a style="color:#24890d" href="https://github.com/memcached/memcached/wiki/SASLHowto">SASL support</a>. Previously Memcached had no authentication layer.</p>

<h2>Summary</h2>
<p style="text-align: justify;">Redis and Memcached are both great and have applications in different areas. Redis being developed later has many advanced functionalities and has great documentation and community.</p>