Free — no signup required

Memcached vs. Redis: The First Choice

3 min read

When you create an ElastiCache cluster, the very first decision is the engine. This choice is permanent — you cannot switch engines without rebuilding the cluster. Understanding the trade-offs is critical.

Memcached: The Simple, Multithreaded Cache

Memcached was designed in 2003 with a single purpose: cache objects as fast as possible. It does that one thing extremely well.

  • Architecture: Truly multithreaded. A single Memcached node can saturate all CPU cores simultaneously, making it highly efficient on large multi-core instance types (e.g., r6g.16xlarge with 64 vCPUs).
  • Data Model: Flat key-value only. Keys are strings; values are opaque blobs (strings, serialized JSON, binary). No structure beyond that.
  • Persistence: None. If the node restarts, all data is gone. This is by design — Memcached treats itself as a disposable cache, not a data store.
  • Replication: None. There is no built-in mechanism to copy data to a standby node.
  • Horizontal Scaling: Client-side sharding only. The application (or a client library) decides which node holds which key. There is no cluster coordination.
  • Use Case: Caching large volumes of simple, homogeneous objects — HTML fragments, serialized API responses, database query results — where data loss on node failure is acceptable and you need maximum throughput on multi-core hardware.

Redis: The Advanced Data Structure Store

Redis (Remote Dictionary Server) was designed as a data structure server, not just a cache. It happens to be extraordinarily fast, which makes it excellent for caching, but its capabilities extend far beyond that.

  • Architecture: Single-threaded command processing (I/O is handled by multiple threads in Redis 6+, but command execution remains serialized). This eliminates lock contention and makes Redis's behavior highly predictable.
  • Data Structures: Strings, Lists (queues/stacks), Sets (unique membership), Sorted Sets (ranked leaderboards), Hashes (field-value maps), Bitmaps, HyperLogLog (cardinality estimation), Streams (append-only log), Geo-spatial indexes.
  • Persistence: Optional. Redis can write snapshots (RDB files) to disk on a schedule, or log every write operation (AOF — Append Only File) for near-zero data loss on restart.
  • Replication: Built-in primary-replica replication with automatic failover (Redis Sentinel / ElastiCache's managed failover).
  • Advanced Features: Pub/Sub messaging, Lua scripting, transactions (MULTI/EXEC), distributed locks (via SET NX PX).
  • Use Case: Session stores, real-time leaderboards, rate limiting, distributed locks, message queues, geospatial queries, and complex caching patterns. Redis is the right choice for 95%+ of modern workloads.

Decision Matrix

Dimension Memcached Redis
Multi-core utilization ✅ Native ⚠️ Limited (single-threaded exec)
Complex data structures
Persistence ✅ Optional
Replication / HA
Horizontal sharding Client-side ✅ Native (Cluster Mode)
Pub/Sub
Typical choice Legacy/simple Modern workloads
Interview Tip

Interviewers frequently ask: "When would you choose Memcached over Redis?" The honest answer is: almost never in a greenfield project. The correct answer is: when you have a workload that is purely simple-object caching, you need maximum multi-core CPU utilization on a single large node, and you explicitly do not need persistence, replication, or complex data structures. In practice, Redis's performance is sufficient for the vast majority of workloads, and its operational advantages (HA, persistence, richer data model) make it the default choice.

This is one of 18 chapters

Get every chapter — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

See pricing