DatabaseJun 20265 min read

Memcached vs Redis

Redis isn't just faster—it's a Swiss Army knife that makes Memcached look like a butter knife. Pick Redis unless you're stuck in 2009.

The short answer

Redis over Memcached for most cases. Redis does everything Memcached does, plus adds persistence, data structures, and pub/sub.

  • Pick Memcached if need more than a dumb cache—think leaderboards, queues, real-time features, or persistence
  • Pick Redis if caching simple strings in a high-throughput, stateless app and value deployment simplicity over features
  • Also consider: Dragonfly—a Redis-compatible drop-in that's multithreaded and claims 25x higher throughput, if raw speed is your bottleneck.

— Nice Pick, opinionated tool recommendations

This Isn't a Fair Fight — It's a Philosophy Clash

Memcached was built in 2003 for one job: cache simple key-value pairs in memory, as fast as possible. It's the bare-metal speed demon that treats data like disposable napkins—when memory fills up, it just throws old stuff away. Redis, launched in 2009, looked at that and said, "What if your cache didn't have to be dumb?" It's a data structure server that caches, persists, queues, and even replicates. Comparing them is like comparing a bicycle (Memcached) to a motorcycle (Redis)—both get you there, but one has an engine, storage, and headlights.

Where Redis Wins — It's Not Just About Cache Hits

Redis wins because it doesn't just cache—it computes. Need sorted sets for leaderboards? Redis has them. Pub/sub for real-time notifications? Built-in. Lua scripting for atomic operations? Yep. It persists to disk with RDB or AOF, so a restart doesn't wipe your cache—try that with Memcached's all-or-nothing memory model. Pricing? Both are open-source, but Redis Labs offers managed hosting from $0.50/GB/month, while Memcached cloud options are rarer and often more expensive. In benchmarks, Redis is within 5% of Memcached's raw speed, but with 10x the features.

Where Memcached Holds Its Own — Simplicity as a Feature

Memcached's strength is its brutal simplicity. No persistence, no data types beyond strings, no replication out-of-the-box—just a lightweight daemon that screams at 500,000 ops/sec on modest hardware. It's easier to deploy (single binary, no config headaches) and scales linearly across nodes because it's dumb and distributed. If all you need is a shared hashmap for session storage or HTML fragment caching, Memcached gets the job done with zero learning curve. It's the tool you set up in 5 minutes and forget about.

The Gotcha — Redis Isn't a Drop-In Replacement

Switching from Memcached to Redis isn't just flipping a switch. Redis uses more memory—about 30-50% extra per key due to rich data structures and overhead. Its persistence can slow writes if you enable AOF with every-append, and clustering requires Redis Cluster (not trivial). Memcached's multi-threaded architecture handles concurrent connections better on multi-core systems, while Redis is single-threaded (though faster per-core). If your app assumes a cache is ephemeral, Redis's persistence might break things—like when it refuses to evict keys because you set maxmemory-policy wrong.

If You're Starting Today, Just Use Redis

Unless you're optimizing for extreme, bare-metal throughput on a legacy stack, pick Redis. Start with a managed service like Redis Cloud ($0.50/GB/month) or AWS ElastiCache ($0.025/hour for t3.micro). Use it for caching, sure, but also for rate limiting with INCR, job queues with lists, and real-time features with pub/sub. Memcached only makes sense if you're in a highly constrained environment—like embedded systems or a 10-year-old PHP app where adding Redis feels like open-heart surgery.

What Most Comparisons Get Wrong — It's Not About Speed

Everyone obsesses over benchmarks showing Memcached 2% faster in GETs. Who cares? The real question is: do you want your cache to just store data, or also manipulate it? Redis's sorted sets alone—think leaderboards with O(log N) updates—justify its use. Memcached can't do that without dumping everything to your app. Also, Redis has a vibrant ecosystem with modules for search (RediSearch) and JSON (RedisJSON), while Memcached's last major update was adding UDP support in 2013. This isn't a speed contest—it's a capability gap.

Data Structures & Persistence — Redis Does More Than Store Strings

Memcached is a glorified key-value store that only handles flat strings. Redis gives you sorted sets, hashes, bitmaps, HyperLogLogs, streams, and geospatial indexes. Need leaderboards? Sorted sets with O(log N) operations. Need real-time analytics? HyperLogLogs approximate unique counts in 12KB. Need message queues? Streams with consumer groups and blocking reads. And persistence? Memcached evaporates on restart. Redis offers RDB snapshots and AOF logs, so your data survives crashes. You can even mix modes: AOF every second for durability, RDB for fast restores. If you think caching is just 'store this string, retrieve it later', you're building 1990s software. Redis turns your cache into a data structure server — and that's why it's the only serious choice.

Multithreading vs Single-Thread — Why Memcached's Parallelism Doesn't Matter

Memcached uses multiple threads to handle concurrent connections, while Redis is single-threaded for command execution. Sounds like Memcached wins, right? Wrong. Redis's single-threaded event loop eliminates locking overhead and race conditions, delivering predictable microsecond latency. Memcached's threading introduces context switches and mutex contention under load. Redis 6+ also added threaded I/O to offload network reads/writes, keeping command execution serialized. Benchmarks show Redis handles 200K+ ops/sec on a single core — more than enough for most use cases. Meanwhile, Memcached's multi-threaded approach only helps if you're bottlenecked on CPU, which you rarely are in caching workloads (network and memory are the limits). Simplicity wins: one thread, no surprises. Memcached's parallelism is a solution in search of a problem.

Real-World Caching — When Memcached Still Wins (Spoiler: Almost Never)

Memcached shines in one narrow scenario: massive, ephemeral key-value caches where you need absolute minimal overhead and don't care about data structures, persistence, or replication. Think CDN origin offload for static blobs, or session stores that can vanish without consequence. Even then, Redis with lazy expiration and eviction policies (allkeys-lfu, volatile-ttl) matches or beats Memcached's memory efficiency. Memcached's slab allocator can cause memory waste (internal fragmentation up to 30%), while Redis's jemalloc keeps it under 10%. And if you ever need to scale reads, Redis replication gives you read replicas; Memcached requires client-side sharding. So when does Memcached actually win? When your ops team refuses to learn anything beyond 'get' and 'set' — and even then, Redis's simplicity is just as easy. Pick Memcached if you're allergic to progress.

Quick Comparison

FactorMemcachedRedis
Data TypesStrings, lists, sets, sorted sets, hashes, streams, bitmapsStrings only
PersistenceRDB snapshots, AOF append-only fileNone—data lost on restart
Max Memory PolicyConfigurable (allkeys-lru, volatile-lru, etc.)LRU eviction only
ReplicationBuilt-in master-slave async replicationNone—requires external tools
Threading ModelSingle-threaded (but faster per-core)Multi-threaded (better concurrency)
Managed Pricing (Entry)Redis Cloud: $0.50/GB/monthAWS ElastiCache for Memcached: ~$0.028/hour for cache.t3.micro
Max Key Size512 MB250 MB
Pub/Sub MessagingBuilt-inNot supported

The Verdict

Use Memcached if: You need more than a dumb cache—think leaderboards, queues, real-time features, or persistence.

Use Redis if: You're caching simple strings in a high-throughput, stateless app and value deployment simplicity over features.

Consider: Dragonfly—a Redis-compatible drop-in that's multithreaded and claims 25x higher throughput, if raw speed is your bottleneck.

Memcached vs Redis: FAQ

Is Memcached or Redis better?

Redis is the Nice Pick. Redis does everything Memcached does, plus adds persistence, data structures, and pub/sub. Memcached is a one-trick pony that's only better at being simple.

When should you use Memcached?

You need more than a dumb cache—think leaderboards, queues, real-time features, or persistence.

When should you use Redis?

You're caching simple strings in a high-throughput, stateless app and value deployment simplicity over features.

What's the main difference between Memcached and Redis?

Redis isn't just faster—it's a Swiss Army knife that makes Memcached look like a butter knife. Pick Redis unless you're stuck in 2009.

How do Memcached and Redis compare on data types?

Memcached: Strings, lists, sets, sorted sets, hashes, streams, bitmaps. Redis: Strings only. Memcached wins here.

Are there alternatives to consider beyond Memcached and Redis?

Dragonfly—a Redis-compatible drop-in that's multithreaded and claims 25x higher throughput, if raw speed is your bottleneck.

🧊
The Bottom Line
Redis wins

Redis does everything Memcached does, plus adds persistence, data structures, and pub/sub. Memcached is a one-trick pony that's only better at being simple.

Related Comparisons

Disagree? nice@nicepick.dev