What Is Amazon ElastiCache? Redis and Memcached on AWS Explained
A chai stall keeps a small kettle of ready tea for rush hour — not boiling every cup from cold water. ElastiCache is that kettle for your app: Redis or Memcached keep hot data in memory so DynamoDB/RDS is not hit for every page view.
What you'll learn in this chapter
- Why caching beats bigger databases alone
- Redis vs Memcached on ElastiCache
- Common patterns: cache-aside, session, leaderboard
- Security, failover, cluster mode basics
- Lab, errors, FAQ, interview
1. Everyday example first
Why do we need this?
A news site homepage hit RDS on every request. During elections CPU melted. Caching the homepage JSON in Redis for 30 seconds dropped DB load by ~90% with acceptable freshness.
What is it?
Amazon ElastiCache is managed Redis (and Redis OSS / Valkey options as AWS evolves) and Memcached in-memory stores. You pick node type, clustering, Multi-AZ, and talk from your app over private network.
2. Redis vs Memcached
| Need | Prefer | Why |
|---|---|---|
| Sessions, leaderboards, locks, pub/sub | Redis | Rich data structures + persistence options |
| Simple object cache, many nodes, multi-thread | Memcached | Simple and horizontally easy |
| Must survive node restart with data | Redis with suitable persistence/repl | AOF/RDB + replicas |
| Lowest ops for key-value only | Either — often Redis by default in 2026 shops |
3. Patterns
- Cache-aside (lazy): app reads cache; on miss loads DB and fills cache.
- Write-through: write DB and cache together (more consistent, more writes).
- Session store: sticky user session in Redis.
- Rate limiting / counters: INCR with TTL.
- Leaderboard: Redis sorted sets.
Ravindra Bagale's Tip
Cache is not a database. If Redis evaporates, your app must still rebuild from the source of truth.
4. Security and networking
- Place nodes in private subnets; security group only from app SG.
- Use AUTH / ACL (Redis) and encryption in-transit when available.
- Do not expose Redis to 0.0.0.0/0 — ever.
- IAM auth options exist for some engines — prefer over long passwords in code; use Secrets Manager.
5. Industries
- Ecommerce: product page and cart fragment cache.
- Gaming: leaderboards and presence.
- Fintech: short-lived OTP / session tokens.
- Media: hot metadata for video catalogs.
- SaaS: multi-tenant rate limits per API key.
6. Mini lab: Redis cache-aside notes
Do this in ap-south-1 (Mumbai) unless your org forbids it. Set a budget alert first.
How to do it (step by step)
- Create a small ElastiCache Redis (cache.t3.micro or current burstable lab size) in private subnet — expect cost; use short TTL lab.
- From a bastion/EC2 in same VPC, redis-cli PING.
- SET lab:hello world EX 60 then GET.
- Sketch cache-aside in your app language on paper.
- CloudWatch: CurrConnections, Evictions, CPU.
Cleanup (stop billing)
- Delete the cluster — Redis bills while available.
- Remove bastion if only for lab.
7. Common errors and fixes
Each row is a real mistake students and juniors hit. Read the fix before you panic.
| Error / symptom | Fix |
|---|---|
| TIMEOUT from app | SG/NACL/subnet route; Redis not public. |
| OOM / evictions spike | Keys without TTL or tiny node — raise memory or TTL. |
| Stampede after expiry | Soft TTL / probabilistic early refresh / lock. |
| Cluster mode keyslot errors | Hash tags for multi-key ops; understand slots. |
| Failover surprise | Test replica promotion in staging. |
| Cached personal data too long | Short TTL + encryption; respect privacy. |
| Using cache as queue forever | Use SQS/Kafka for queues. |
| Wrong engine version client | Match redis-py / lettuce versions. |
| Multi-AZ off in prod | Enable for prod Redis. |
| Bill after "stopped" | ElastiCache is deleted not stopped like EC2 — delete cluster. |
8. Troubleshooting checklist
- Security group: app → Redis port (6379 default) only.
- Same VPC / peered path exists.
- AUTH token correct from Secrets Manager.
- TLS flag matches cluster setting.
- Monitor Evictions and CPU before scaling vertically.
9. FAQ
Q. ElastiCache vs DynamoDB DAX?
DAX is DynamoDB-specific acceleration; ElastiCache is general Redis/Memcached.
Q. Redis persistence on ElastiCache?
Replicas + optional persistence features — still design for cache loss.
Q. Memcached dead?
Still valid for simple caches; Redis dominates feature requests.
Q. Serverless ElastiCache?
AWS has been expanding serverless cache options — check current console for your region.
Q. How big should TTL be?
Business freshness: homepage 30s; profile 300s; config 60s — measure.
10. Interview Q&A
Q. What is ElastiCache?
Managed Redis/Memcached in-memory store on AWS.
Q. Cache-aside?
Read cache; on miss read DB and populate cache with TTL.
Q. Redis vs Memcached?
Redis: rich structures; Memcached: simple multi-node KV.
Q. How do you secure it?
Private subnets, tight SG, AUTH/ACL, encryption, no public access.
Q. Thundering herd?
Dogpile lock / staggered TTL / soft expire.
Q. When not to cache?
Strongly consistent writes every read must see; tiny rarely-read datasets.
11. Tips in English, Marathi and Hindi
Ravindra Bagale's Tip (EN)
Put TTL on every key in labs and in prod unless you have a written exception.
Ravindra Bagale's Tip (MR)
Lab आणि prod मध्ये प्रत्येक key ला TTL — लिहिलेली exception सोडून.
Tip (HI)
हर key पर TTL रखो — लिखित exception छोड़कर।
Try at home
- Draw cache-aside for a product API on paper.
- Compare Redis vs Memcached in 5 bullets for an interview.
- Estimate monthly cost of cache.t3.micro in ap-south-1 (pricing page).
In short
- ElastiCache = managed in-memory Redis/Memcached.
- Prefer Redis for most app patterns in 2026.
- Private + AUTH + TTL always.
- Delete lab clusters — they bill while available.
Revision, interview and comparison cards
Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.











More cards: Ravi Sir's Cards.
Practice Tasks
Shivneri Schools is a education business in Junnar. Kavita Shinde looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.
0 / 16
Easy Describe cache clusters
Why: See Redis/Memcached.
What to do: Describe cache clusters in ap-south-1.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Delete cache cluster
Why: Stop lab cost.
What to do: Delete cache cluster shivnerischool-redis.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Describe cache subnet groups
Why: Place cache in VPC.
What to do: Describe cache subnet groups.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Describe parameter groups
Why: Tune redis params.
What to do: Describe cache parameter groups.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Default Redis port
Why: Security groups need the port.
What to do: Default Redis port number?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Easy Default Memcached port
Why: Different from Redis.
What to do: Default Memcached port number?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Reboot cache cluster
Why: Apply maintenance.
What to do: Reboot cache cluster shivnerischool-redis.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Create cache subnet group
Why: Multi-AZ placement.
What to do: Create cache subnet group shivnerischool-sub with subnet-ids subnet-aaa subnet-bbb description lab.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Modify cluster node type
Why: Scale vertically.
What to do: Modify cache cluster shivnerischool-redis to cache-node-type cache.t3.small apply-immediately.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Describe replication groups
Why: Redis HA.
What to do: Describe replication groups.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Single-node Redis lab nodes
Why: Lab uses one node.
What to do: How many cache nodes in a single-node Redis cluster?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Connection endpoint JSON
Why: Apps need host and port.
What to do: JSON endpoint Address redis.example.cache.amazonaws.com Port 6379.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Fill in each property with the value from the task.
- Click Check answer. Key order does not matter.
Hard Create Redis cluster
Why: Session cache.
What to do: Create cache cluster shivnerischool-redis engine redis cache-node-type cache.t3.micro num-cache-nodes 1.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Hard Create Memcached cluster
Why: Simple object cache.
What to do: Create cache cluster shivnerischool-mc engine memcached cache-node-type cache.t3.micro num-cache-nodes 2.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Hard Deny opening Redis to world
Why: Never 0.0.0.0/0 on 6379 in prod stories.
What to do: Deny ec2:AuthorizeSecurityGroupIngress on *.
- Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
- In each statement write Effect, Action and Resource.
- Give only what the task needs (least privilege).
- Use double quotes and commas correctly. Click Check answer.
Hard Auth token length rule quiz doc
Why: Redis AUTH.
What to do: JSON auth with TokenLength 32 Min 16 Max 128.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Fill in each property with the value from the task.
- Click Check answer. Key order does not matter.