Redis vs Memcached
Redis is a rich data-structure server with persistence and replication; Memcached is a lean, multithreaded string cache. Pick by feature needs vs raw simplicity.
By Ratish Jain · Updated
The Decision
Both are in-memory key-value stores sitting in front of a slower database, and both deliver sub-millisecond reads. But they solve different problems. Memcached is deliberately minimal: a multithreaded cache of opaque strings, designed to be dead-simple and to scale reads linearly across CPU cores.
Redis is a data-structure server. It stores lists, hashes, sets, sorted sets, streams and bitmaps, supports persistence, replication, pub/sub and Lua scripting. That power costs some simplicity.
So it depends on whether you need a plain, horizontally-partitioned string cache (Memcached) or a versatile datastore that also happens to be a cache (Redis).
Side by Side
| Redis | Memcached | |
|---|---|---|
| Data model | Strings, hashes, lists, sets, sorted sets, streams | Strings/blobs only |
| Threading | Mostly single-threaded core (I/O threads added later) | Fully multithreaded |
| Persistence | RDB snapshots + AOF log | None; purely volatile |
| Replication / HA | Built-in replicas, Sentinel, Cluster | None natively; client-side sharding |
| Eviction | Multiple policies incl. LRU/LFU/TTL | Slab-based LRU |
| Extra features | Pub/sub, transactions, scripting, geo | Minimal, cache-only |
| Memory efficiency | Higher overhead per key | Very lean for large flat values |
Redis Strengths & Weaknesses
- Rich data structures enable leaderboards, queues, rate limiters without extra systems
- Persistence and replication give durability and high availability
- Pub/sub, streams and Lua scripting reduce round trips
- Single-threaded core can bottleneck on a hot instance
- More memory overhead and operational surface to tune
- Feature richness invites misuse as a primary database
Decision Guide
Choose Redis when you need data structures, persistence, replication, pub/sub, or atomic server-side operations — it is the default for most modern systems. Choose Memcached when you want a pure, simple, multithreaded string cache that scales across cores with minimal ops, and you can tolerate losing the entire cache on restart.
Real-World Examples
- Historically used Memcached at massive scale for simple timeline/object caching
- GitHub
- Uses Redis for queues, rate limiting and ephemeral state
- Stack Overflow
- Runs Redis for caching plus pub/sub across web tiers
- Built mcrouter to scale Memcached across huge fleets
Interview Questions
Memcached is fully multithreaded and can saturate many cores for simple get/set, while Redis's command execution is single-threaded, so a very hot flat-string workload can favor Memcached.
Persistence and replication mean a restart or failover does not cold-start every cache, and the data structures often eliminate other infrastructure — the operational value usually outweighs Memcached's raw simplicity.
- →Memcached = simple, multithreaded, volatile string cache.
- →Redis = data-structure server with persistence, replication, pub/sub.
- →Redis core is single-threaded; Memcached scales across cores.
- →Redis survives restarts via RDB/AOF; Memcached loses everything.
- →Default to Redis unless you specifically want minimal string caching.
Related
Everything on Archprimer is connected — follow the graph.