Redis vs Memcached — When Your Cache Needs More Than Just Speed
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.
Redis
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.
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.
Quick Comparison
| Factor | Redis | Memcached |
|---|---|---|
| Data Types | Strings, lists, sets, sorted sets, hashes, streams, bitmaps | Strings only |
| Persistence | RDB snapshots, AOF append-only file | None—data lost on restart |
| Max Memory Policy | Configurable (allkeys-lru, volatile-lru, etc.) | LRU eviction only |
| Replication | Built-in master-slave async replication | None—requires external tools |
| Threading Model | Single-threaded (but faster per-core) | Multi-threaded (better concurrency) |
| Managed Pricing (Entry) | Redis Cloud: $0.50/GB/month | AWS ElastiCache for Memcached: ~$0.028/hour for cache.t3.micro |
| Max Key Size | 512 MB | 250 MB |
| Pub/Sub Messaging | Built-in | Not supported |
The Verdict
Use Redis if: You need more than a dumb cache—think leaderboards, queues, real-time features, or persistence.
Use Memcached 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.
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