Need advice about which tool to choose?Ask the StackShare community!

Memcached

5.4K
3.7K
+ 1
466
Redis

38.3K
28.1K
+ 1
3.9K
Add tool

Memcached vs Redis: What are the differences?

Memcached: High-performance, distributed memory object caching system. Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering; Redis: An in-memory database that persists on disk. Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

Memcached can be classified as a tool in the "Databases" category, while Redis is grouped under "In-Memory Databases".

"Fast object cache", "High-performance" and "Stable" are the key factors why developers consider Memcached; whereas "Performance", "Super fast" and "Ease of use " are the primary reasons why Redis is favored.

Memcached and Redis are both open source tools. It seems that Redis with 37.4K GitHub stars and 14.4K forks on GitHub has more adoption than Memcached with 9K GitHub stars and 2.6K GitHub forks.

According to the StackShare community, Redis has a broader approval, being mentioned in 3261 company stacks & 1782 developers stacks; compared to Memcached, which is listed in 755 company stacks and 267 developer stacks.

Decisions about Memcached and Redis
Matthew Evans

The obvious volatile memory choices were either Memcached or Redis. We eventually sided with Redis as it natively handled replication, and this replication fell under the PCI responsibility scope of AWS. This added duribility meant that if a redis node were to die, our downtime would be in the seconds, rather than 15 minutes which we would incur using Memcached

See more
Mark Harrison

The requirement was the classic "cache the results of a SQL query for a period of time."

While the Internet is full of "Redis is fuller featured" posts, the key issue for us was the actual performance. We discovered, in various stress scenario testing, that Memcached outperformed Redis for simple key-value retrieval dramatically (over twice as fast.) That's not to say that Redis is bad - we use that in other places where the requirements are more sophisticated than simple key/value retrieval.

See more
 This was roughly 4 years ago at this point. We had been using an old iteration of memcache on Windows as the data cache per server for while and had for whatever reason opted to store our session data (to which the application is heavily dependent) in App Fabric. App Fabric had come to EOL and we needed to move away from it. As a quick search showed throughput capacity to be higher and overall features of Redis were better we initially implemented it. The number of changes required were minimal and we were able to migrate away to a more resilient system pretty quickly.
 We hit a snag in that the implementation of the Redis session handler at that point only took a single IP so we had to do use keepalived and HAProxy to display the application consistently between master and slave failovers. This caused issues on occasion of dropped connections to the backend service. We upgraded our client and could put both members into our config files and it stopped timing out. We were all happy in this and it was (for it's own part) a significant upgrade. Generally performance was better for all pages. 
 We found however, that our application was serializing all requests and locking on the thread via session lock for a great many things and this caused us and our users considerable headaches on occasion. We found that the implementation of the couchbase session handler gave us the option of ignoring session write locks and not be required to rewrite dozens of pages to handle the no session requirement as the application was working fine without the need to be threadsafe. Though the maximum throughput was not as good compared to Redis the application performance was considerably better as a result of the change. The multi-master write was a big benefit and the cross data center replication was a nice thing to have as that would allow our users to remain logged in even across DataCenter fail-over events (praying that never happened). Overall we used that for session handling and chose to use couchbase (in a 2nd cluster) to handle memcache requests as that gave us greater capacity to handle larger objects more efficiently. 
 We are, all these years later, looking to move into the newer features of couchbase to give us more and better use of this product that really has been the answer to a bunch of the growing pains we experienced. Since the decision performance has not been on wild rides and stability has never been better. So I sing the praises of couchbase to anyone that will listen.
See more
Get Advice from developers at your company using Private StackShare. Sign up for Private StackShare.
Learn More
Pros of Memcached
Pros of Redis
  • 136
    Fast object cache
  • 127
    High-performance
  • 90
    Stable
  • 65
    Mature
  • 32
    Distributed caching system
  • 11
    Improved response time and throughput
  • 3
    Great for caching HTML
  • 2
    Putta
  • 877
    Performance
  • 535
    Super fast
  • 511
    Ease of use
  • 442
    In-memory cache
  • 321
    Advanced key-value cache
  • 190
    Open source
  • 179
    Easy to deploy
  • 163
    Stable
  • 153
    Free
  • 120
    Fast
  • 40
    High-Performance
  • 39
    High Availability
  • 34
    Data Structures
  • 32
    Very Scalable
  • 23
    Replication
  • 20
    Great community
  • 19
    Pub/Sub
  • 17
    "NoSQL" key-value data store
  • 14
    Hashes
  • 12
    Sets
  • 10
    Sorted Sets
  • 9
    Lists
  • 8
    BSD licensed
  • 8
    NoSQL
  • 7
    Async replication
  • 7
    Integrates super easy with Sidekiq for Rails background
  • 7
    Bitmaps
  • 6
    Open Source
  • 6
    Keys with a limited time-to-live
  • 5
    Strings
  • 5
    Lua scripting
  • 4
    Awesomeness for Free!
  • 4
    Hyperloglogs
  • 3
    outstanding performance
  • 3
    Runs server side LUA
  • 3
    Networked
  • 3
    LRU eviction of keys
  • 3
    Written in ANSI C
  • 3
    Feature Rich
  • 3
    Transactions
  • 2
    Data structure server
  • 2
    Performance & ease of use
  • 1
    Existing Laravel Integration
  • 1
    Automatic failover
  • 1
    Easy to use
  • 1
    Object [key/value] size each 500 MB
  • 1
    Simple
  • 1
    Channels concept
  • 1
    Scalable
  • 1
    Temporarily kept on disk
  • 1
    Dont save data if no subscribers are found
  • 0
    Jk

Sign up to add or upvote prosMake informed product decisions

Cons of Memcached
Cons of Redis
  • 1
    Only caches simple types
  • 12
    Cannot query objects directly
  • 1
    No WAL
  • 1
    No secondary indexes for non-numeric data types

Sign up to add or upvote consMake informed product decisions

What is Memcached?

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

What is Redis?

Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

Need advice about which tool to choose?Ask the StackShare community!

What companies use Memcached?
What companies use Redis?
See which teams inside your own company are using Memcached or Redis.
Sign up for Private StackShareLearn More

Sign up to get full access to all the companiesMake informed product decisions

What tools integrate with Memcached?
What tools integrate with Redis?

Sign up to get full access to all the tool integrationsMake informed product decisions

Blog Posts

Dec 22 2020 at 9:26PM

Pinterest

+4
9
2189
Nov 20 2019 at 3:38AM

OneSignal

+8
7
3735
Jun 6 2019 at 5:11PM

AppSignal

+9
15
1076
+17
32
28379
What are some alternatives to Memcached and Redis?
Ehcache
Ehcache is an open source, standards-based cache for boosting performance, offloading your database, and simplifying scalability. It's the most widely-used Java-based cache because it's robust, proven, and full-featured. Ehcache scales from in-process, with one or more nodes, all the way to mixed in-process/out-of-process configurations with terabyte-sized caches.
Varnish
Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. Varnish Cache is really, really fast. It typically speeds up delivery with a factor of 300 - 1000x, depending on your architecture.
Hazelcast
With its various distributed data structures, distributed caching capabilities, elastic nature, memcache support, integration with Spring and Hibernate and more importantly with so many happy users, Hazelcast is feature-rich, enterprise-ready and developer-friendly in-memory data grid solution.
MongoDB
MongoDB stores data in JSON-like documents that can vary in structure, offering a dynamic, flexible schema. MongoDB was also designed for high availability and scalability, with built-in replication and auto-sharding.
Couchbase
Developed as an alternative to traditionally inflexible SQL databases, the Couchbase NoSQL database is built on an open source foundation and architected to help developers solve real-world problems and meet high scalability demands.
See all alternatives
Reviews of Memcached and Redis
Review of
Redis

Redis is a good caching tool for a cluster, but our application had performance issues while using Aws Elasticache Redis since some page had 3000 cache hits per a page load and Redis just couldn't quickly process them all in once + latency and object deseialization time - page load took 8-9 seconds. We create a custom hybrid caching based on Redis and EhCache which worked great for our goals. Check it out on github, it's called HybriCache - https://github.com/batir-akhmerov/hybricache.

How developers use Memcached and Redis
Cloudcraft uses
Redis

Redis is used for storing all ephemeral (that's data you don't necessarily want to store permanently) user data, such as mapping of session IDs (stored in cookies) to current session variables at Cloudcraft.co. The many datastructures supported by Redis also makes it an excellent caching and realtime statistics layer. It doesn't hurt that the author, Antirez, is the nicest guy ever! These days, I would be really hard pressed to find any situation where I would pick something like Memcached over Redis.

Trello uses
Redis

Trello uses Redis for ephemeral data that needs to be shared between server processes but not persisted to disk. Things like the activity level of a session or a temporary OpenID key are stored in Redis, and the application is built to recover gracefully if any of these (or all of them) are lost. We run with allkeys-lru enabled and about five times as much space as its actual working set needs, so Redis automatically discards data that hasn鈥檛 been accessed lately, and reconstructs it when necessary.

Stack Exchange uses
Redis

The UI has message inbox that is sent a message when you get a new badge, receive a message, significant event, etc. Done using WebSockets and is powered by redis. Redis has 2 slaves, SQL has 2 replicas, tag engine has 3 nodes, elastic has 3 nodes - any other service has high availability as well (and exists in both data centers).

Brandon Adams uses
Redis

Redis makes certain operations very easy. When I need a high-availability store, I typically look elsewhere, but for rapid development with the ability to land on your feet in prod, Redis is great. The available data types make it easy to build non-trivial indexes that would require complex queries in postgres.

Kent Steiner uses
Redis

I use Redis for cacheing, data storage, mining and augmentation, proprietary distributed event system for disparate apps and services to talk to each other, and more. Redis has some very useful native data types for tracking, slicing and dicing information.

Reactor Digital uses
Memcached

As part of the cacheing system within Drupal.

Memcached mainly took care of creating and rebuilding the REST API cache once changes had been made within Drupal.

Casey Smith uses
Memcached

Distributed cache exposed through Google App Engine APIs; use to stage fresh data (incoming and recently processed) for faster access in data processing pipeline.

The Independent uses
Memcached

Memcache caches database results and articles, reducing overall DB load and allowing seamless DB maintenance during quiet periods.

eXon Technologies uses
Memcached

Used to cache most used files for our clients. Connected with CloudFlare Railgun Optimizer.

ScholaNoctis uses
Memcached

Memcached is used as a simple page cache across the whole application.