Amazon ElastiCache
In-memory cache (Redis)
Managed Redis/Valkey/Memcached that keeps data in RAM for reads many times faster than a database.
- Cost$$ Medium
- Difficulty●●●●●
- Costs money when idle?Yes
- Managed by AWS
- In examsSAA · DVA · SOA
Think of it asLike a sticky note on your desk: frequently used info is right there, no need to open the cabinet.
Where does ElastiCache fit?
Calls ElastiCache
A real example, step by step
- A news site's home page makes 50 database calls per view, and at peak times the database is overloaded.
- You create an ElastiCache for Valkey cluster (Redis compatible) with a replica in another AZ.
- The app checks the cache first; only on a miss does it query the database, then it caches the result for 60 seconds.
- Most requests are now served from memory in under a millisecond, and the database load drops sharply.
- Login sessions also move to ElastiCache, so if a web server fails, users aren't logged out.
When to use it
✓ Use it when
Caching DB queries, storing sessions, leaderboards.
✗ Avoid it when
Primary data that needs absolute durability → a database.
Common uses
- Cache queries to offload RDS
- Store web sessions
- Leaderboards, rate limiting, real-time pub/sub
ElastiCache, DynamoDB or RDS?
| Role | Cache, session store | Primary database (NoSQL) | Primary database (SQL) |
|---|---|---|---|
| Speed | Under 1 millisecond (in memory) | A few milliseconds | Depends on the query |
| Durability | Not a database replacement; has replication and backups | Durable, multi-AZ | Durable, with backups |
| Billing | Per node per hour, or serverless | Per request or capacity | Instance hours + storage |
What does it cost?
- Pricing model: Per node-hour (e.g. cache.t4g.micro ~$0.016/hour) or ElastiCache Serverless per GB of data and processing units (ECPU).
- Free tier: Older accounts: 750 hours of cache.t*.micro for 12 months.
Serverless has a minimum billed data amount; clusters oversized for the need; cross-AZ data transfer between app and cache.
“Reduce read load on the database” or “don't lose sessions when a web server fails” → ElastiCache. Need replication, failover and rich data types → Redis/Valkey; simple multi-threaded caching only → Memcached. A cache just for DynamoDB → DAX.
Try real exam questions
1A company runs a web application on Amazon EC2 instances in an Auto Scaling group behind an Application Load Balancer that has sticky sessions enabled. The web server currently hosts the user session state. The company wants to ensure high availability and avoid user session state loss in the event of a web server outage. Which solution will meet these requirements?
- AUse an Amazon ElastiCache for Memcached instance to store the session data. Update the application to use ElastiCache for Memcached to store the session state.
- BUse Amazon ElastiCache for Redis to store the session state. Update the application to use ElastiCache for Redis to store the session state.
- CUse an AWS Storage Gateway cached volume to store session data. Update the application to use AWS Storage Gateway cached volume to store the session state.
- DUse Amazon RDS to store the session state. Update the application to use Amazon RDS to store the session state.
Show answer
Correct answer: B
Move sessions off the web servers into ElastiCache for Redis (with replication and automatic failover). If one server fails, users keep their sessions. Memcached has no replication, so data can still be lost.
2What does Amazon ElastiCache provide?
- AA service by this name doesn't exist. Perhaps you mean Amazon CloudCache.
- BA virtual server with a huge amount of memory.
- CA managed In-memory cache service.
- DAn Amazon EC2 instance with the Memcached software already pre-installed.
Show answer
Correct answer: C
ElastiCache is a managed in-memory caching service (Redis, Valkey, Memcached).
Frequently asked questions
Should ElastiCache use Redis (Valkey) or Memcached?
Redis OSS and Valkey offer rich data types, replication, automatic failover, backups and persistence, and fit most use cases. Memcached is simple and multi-threaded, for pure caching only, with no replication or persistence.
What is the difference between ElastiCache and DAX?
DAX is a cache only for DynamoDB and needs almost no code changes. ElastiCache is a general-purpose cache for any data source (RDS, APIs, computed results) and for session storage, but your application must implement the caching logic itself.
How is ElastiCache priced?
Node-based clusters are billed per node per hour and run continuously even with no requests. ElastiCache Serverless is billed by the amount of data stored and the processing units (ECPUs) actually used.
What do AWS exams ask about ElastiCache?
Offloading reads from a database, storing sessions so applications stay stateless, choosing Redis or Memcached, lazy loading and write-through caching strategies, and enabling Multi-AZ for automatic failover.