Service · Database · Builds on CLF-C02
Amazon ElastiCache
In-memory cache. Choose Valkey or Redis OSS for rich features, Memcached for a simple multithreaded cache.
You know from Cloud Practitioner
- ElastiCache answers in microseconds and takes read load off a database.
- Engines are Valkey, Redis OSS and Memcached.
- A cache keeps copies. The database still holds the main data.
Data types
- Valkey or Redis OSS
- Lists, sets, sorted sets, hashes
- Memcached
- Simple strings and objects
Replication
- Valkey or Redis OSS
- Replicas, automatic failover
- Memcached
- None
Persistence
- Valkey or Redis OSS
- Snapshots and backups
- Memcached
- None on node-based clusters. Serverless Memcached can take backups.
Threads
- Valkey or Redis OSS
- Mostly single-threaded per shard
- Memcached
- Multithreaded
Scale
- Valkey or Redis OSS
- Cluster mode shards
- Memcached
- Add nodes
| Compare | Valkey or Redis OSS | Memcached |
|---|---|---|
| Data types | Lists, sets, sorted sets, hashes | Simple strings and objects |
| Replication | Replicas, automatic failover | None |
| Persistence | Snapshots and backups | None on node-based clusters. Serverless Memcached can take backups. |
| Threads | Mostly single-threaded per shard | Multithreaded |
| Scale | Cluster mode shards | Add nodes |
1 / 2
Data types
- Valkey or Redis OSS
- Lists, sets, sorted sets, hashes
- Memcached
- Simple strings and objects
Replication
- Valkey or Redis OSS
- Replicas, automatic failover
- Memcached
- None
Persistence
- Valkey or Redis OSS
- Snapshots and backups
- Memcached
- None on node-based clusters. Serverless Memcached can take backups.
| Compare | Valkey or Redis OSS | Memcached |
|---|---|---|
| Data types | Lists, sets, sorted sets, hashes | Simple strings and objects |
| Replication | Replicas, automatic failover | None |
| Persistence | Snapshots and backups | None on node-based clusters. Serverless Memcached can take backups. |
2 / 2
Threads
- Valkey or Redis OSS
- Mostly single-threaded per shard
- Memcached
- Multithreaded
Scale
- Valkey or Redis OSS
- Cluster mode shards
- Memcached
- Add nodes
| Compare | Valkey or Redis OSS | Memcached |
|---|---|---|
| Threads | Mostly single-threaded per shard | Multithreaded |
| Scale | Cluster mode shards | Add nodes |
What it is
Valkey and Redis OSS support rich data types (lists, sets, sorted sets, hashes), replicas with automatic failover, snapshots and publish-subscribe messaging. They suit leaderboards, session stores and queues. Cluster mode splits the data over several shards, so you can scale memory and writes. Memcached is simpler: strings and objects, no replication, no persistence, but it uses many threads and scales by adding nodes.
What it is
DynamoDB Accelerator (DAX) is a cache made for DynamoDB. It speeds up reads from milliseconds to microseconds and uses the same DynamoDB API, so the application changes little. It caches items and query results, and it writes through to the table. Use ElastiCache for any other database or for computed data.
Size the cache to hold the hot data, the “working set”. When memory is full, the engine evicts keys, often the least recently used, or you set a time to live (TTL) on each key.
Remember
- Valkey and Redis OSS: data types, replicas, automatic failover, backups, cluster mode.
- Memcached: simple, multithreaded, no replication and no persistence. A node failure loses that node’s data.
- DAX is the cache for DynamoDB. It needs no application redesign.
- Use ElastiCache for session state, leaderboards and repeated database reads.
Remember
- Eviction when memory is full: least recently used, or keys expire by TTL.
- ElastiCache Serverless needs no node sizing.
On the exam
- “Microsecond reads for a DynamoDB table with minimal code change” points to DAX.
- “Sorted leaderboard, sessions, replication and failover” points to ElastiCache for Valkey or Redis OSS.
- “Simple, multithreaded object cache” points to Memcached.
- “Reduce load on a relational database for repeated queries” points to ElastiCache.
Do not mix it up with
Amazon DynamoDBServerless key-value and document database. Design the key well and choose the capacity mode.
- Read replicasCopies of a database that serve reads. They add read capacity, not high availability.
- Caching strategiesKeep a copy of hot data close to the reader: at the edge, in front of the API, in memory next to the database.