Redis vs Memcached: When the Simpler One Wins
Most comparisons of these two are a feature table, and a feature table always declares Redis the winner, because Redis does more things. That framing hides the actual question, which is whether doing more things is an advantage for the job you have.
Memcached is a distributed hash table. Keys to opaque byte strings, with an expiry. That is the entire product.
Redis is a data-structure server. Strings, hashes, lists, sorted sets, streams, bitmaps, HyperLogLogs, geospatial indexes — with optional persistence, replication, scripting and pub/sub.
Where Memcached genuinely wins
It is multithreaded. Memcached uses every core on the box for command execution. Redis executes commands on a single thread — deliberately, because that is what makes every Redis operation atomic without locks. On a 16-core machine serving a simple, extremely high-throughput cache, Memcached can use the hardware in a way one Redis process cannot.
The usual Redis answer is to run multiple instances or a cluster, which works and is more moving parts than one Memcached.
Lower memory overhead per key. Memcached stores a value and little else. Its slab allocator groups similar-sized objects into fixed classes, which resists fragmentation over long uptimes. Redis carries type information, expiry structures and more per-key metadata. At a few million keys that difference is noticeable; at a hundred million it is a hardware budget.
The slab allocator has a real downside worth knowing: if your value sizes shift over time, memory assigned to one slab class is not easily reclaimed for another, and you can be “full” with free space in the wrong bucket.
Operational simplicity. There is almost nothing to configure and almost nothing to get wrong. No persistence to reason about, no eviction policy debate, no accidental use as a database.
Where Redis wins, which is most of the time
Data structures remove round trips. A leaderboard is one sorted set, not “fetch the list, sort in your application, write it back”. Rate limiting is one atomic increment with an expiry. A queue is a list. Every one of those in Memcached is a read-modify-write, which is both slower and racy.
Atomic operations. Because commands run on one thread, INCR, SETNX and
Lua scripts are atomic without coordination. Memcached has incr and add but
nothing like the composability.
Persistence and replication. RDB snapshots and the AOF log mean a restart does not necessarily start cold. Replication and Sentinel or Cluster give failover. Memcached restarts empty, always — which is fine for a cache and fatal for anything else.
Better eviction control. Redis offers several policies — allkeys-lru,
volatile-ttl, allkeys-lfu and more. LFU in particular is meaningfully better
than LRU when a small set of keys is hot and a long tail is scanned
occasionally, because LRU lets a one-off scan evict your working set.
Pub/sub and streams, if you want them — though a real broker is a better choice once the workload is serious. See Kafka vs RabbitMQ for that decision.
The comparison
| Memcached | Redis | |
|---|---|---|
| Data model | strings only | strings, hashes, lists, sets, sorted sets, streams |
| Threading | multithreaded | single-threaded commands (I/O threads in 6+) |
| Memory per key | lower | higher |
| Persistence | none | RDB snapshots, AOF |
| Replication / failover | none built in | replication, Sentinel, Cluster |
| Atomic compound ops | minimal | rich, plus Lua |
| Eviction policies | LRU | LRU, LFU, TTL-based, several |
| Max value size | 1 MB default | 512 MB |
| Operational surface | tiny | substantial |
Choosing
Default to Redis. Not because it wins every benchmark, but because most caching workloads eventually want one thing a plain hash table cannot do, and discovering that after you have built on Memcached is a migration.
Choose Memcached when all of these hold: values are opaque blobs, the access pattern is genuinely get and set, the key count is very large, throughput is high enough that multithreading matters, and losing the entire cache is a non-event. That is a real profile — large-scale page and fragment caching in front of a web tier is exactly it.
Do not run both to hedge. Two caching systems is two eviction models, two monitoring setups and two failure modes, to save an amount of RAM that is cheaper than the engineering time.
What you have actually chosen
Whether your cache is allowed to become part of the system.
Memcached can only ever be a cache, and there is genuine safety in that constraint — nothing you build can quietly come to depend on it surviving. Redis can be a cache, and a queue, and a lock manager, and a session store, and by the time it is all four, it is a database you never designed for durability. Pick the constraint you want, then hold to it.
Quick answers
- Is Redis always better than Memcached?
- No. For a pure key-to-blob cache with large values and high concurrency, Memcached is often faster and uses less memory per key, because it is multithreaded and stores nothing but the value. Redis wins when you need data structures, persistence, pub/sub or atomic operations.
- Is Memcached multithreaded and Redis single-threaded?
- Yes for command execution. Memcached scales across cores on one node, while Redis executes commands on a single thread — which is what makes its operations atomic. Redis 6+ uses extra threads for network I/O, but command execution remains single-threaded.
- Which uses less memory, Redis or Memcached?
- Memcached generally has lower per-key overhead and its slab allocator resists fragmentation, so for millions of small, uniform entries it stores more in the same RAM. Redis carries more metadata per key in exchange for types and expiry semantics.
- Can Redis replace Memcached entirely?
- Functionally yes — Redis does everything Memcached does. The reason to keep Memcached is operational: one job, almost no configuration, and predictable behaviour under a pure caching workload. Most teams should still default to Redis for the flexibility.
References
Related Discoveries
Lumi's weekly note
A short email when we publish something useful. No spam, unsubscribe anytime.