SysPadLessons › database lessons › ElastiCache (Memcached)

How ElastiCache (Memcached) works

Multi-threaded in-memory key-value cache. Data is partitioned across nodes (no replication), so throughput scales with node count and vCPU. Best for simple, high-throughput caching.

Memcached is the cache stripped to its bones: a giant, blazing-fast hash table in RAM and almost nothing else. No persistence, no replication, no failover, no fancy data types. That sounds limiting, but the simplicity is the feature, and it’s multithreaded, so it scales straight up with CPU cores.

What you will learn

A cache stripped to its bones

Memcached stores simple key → value pairs (strings/serialized objects) in memory and serves them fast. There’s no persistence, no replication, and no automatic failover, if a node restarts, its contents are simply gone.

For a pure, rebuildable cache, all those missing features are things you don’t have to pay for or reason about.

Multithreaded: scales with cores

Unlike Redis (single-threaded command execution), Memcached is multithreaded: one node uses many CPU cores at once. On a large multi-core node it can push very high throughput for plain get/set traffic.

Great for high-volume, simple caching: HTML fragments, database query results, session blobs.

The client does the sharding

Memcached nodes are independent and unaware of each other. The client picks which node holds a key (by hashing it) and always routes that key to the same node. Adding nodes grows total memory and throughput.

When to pick Redis/Valkey instead

Reach for Redis/Valkey when you need more than a plain cache: rich data structures (lists, sorted sets, streams), replication and automatic failover, pub/sub, or any durability story.

Flashcards

What does Memcached deliberately NOT do?
No persistence, no replication, no automatic failover, and no rich data types, just a fast in-memory key → value store.
How does Memcached push higher single-node throughput than Redis on get/set traffic?
It’s multithreaded, using many CPU cores per node, whereas Redis executes commands on a single thread.
In a Memcached cluster, who decides which node holds a given key?
The client, by hashing the key. Nodes are independent and don’t coordinate; add nodes to add memory and throughput.
A Memcached node fails. What happens to its keys?
They’re lost and become cache misses, then get repopulated from the source. There’s no replication, so nothing fails over.
When should you choose Redis/Valkey over Memcached?
When you need data structures, replication/automatic failover, pub/sub, or any durability, anything beyond a plain rebuildable cache.

Sources

Open the SysPad canvas · Official ElastiCache (Memcached) documentation

Other database lessons