Amazon ElastiCache

Managed Valkey, Redis OSS, or Memcached. Same trade-offs as if you ran them yourself — but AWS handles OS, patching, failover, backups. App code still needs to know about cache.

Valkey, Redis OSS hoặc Memcached managed. Vẫn cùng trade-off nếu bạn tự chạy — nhưng AWS lo OS, patching, failover, backup. Code app vẫn phải biết đến cache.

Reach for itNên dùng

  • Read-heavy DB — shave 90 %+ off RDS readsDB đọc nhiều — bớt 90 %+ tải đọc RDS
  • Sessions / sticky data → stateless app tierSession / data sticky → app tier stateless
  • Rate-limiting, counters, leaderboards (Redis)Rate-limit, counter, leaderboard (Redis)

Skip itBỏ qua

  • DynamoDB in front of you — use DAX insteadĐang dùng DynamoDB — dùng DAX
  • You can't modify app code to look up cache firstKhông sửa được code app để check cache trước
  • Durable persistence is a hard requirement — pick a DBCần persist bền vững — chọn DB

Valkey / Redis OSS vs MemcachedValkey / Redis OSS vs Memcached

Valkey · Redis OSS Memcached
Data typesKiểu data String · hash · list · set · zset · streamString · hash · list · set · zset · stream Key → string onlyChỉ key → string
PersistencePersist ✅ RDB snapshot (no AOF on ElastiCache)✅ RDB snapshot (ElastiCache không có AOF) ❌
HAHA Multi-AZ · auto-failover · read replicasMulti-AZ · auto-failover · read replica Multi-node sharding, no failoverShard đa node, không failover
Atomic opsAtomic ✅ ❌
Pub/Sub · Lua ✅ ❌
ThreadingThreading Single-threaded (per shard)Đơn luồng (mỗi shard) Multi-threadedĐa luồng
Scale-outScale-out Cluster mode: up to 500 shards · ≤ 5 replicas/shard (max 500 nodes)Cluster mode: tối đa 500 shard · ≤ 5 replica/shard (max 500 node) ≤ 40 nodes · client-side sharding≤ 40 node · shard phía client
Cross-regionCross-region ✅ Global Datastore — async, <1 s lag, read-only secondaries, promote for DR (~1 min)✅ Global Datastore — async, lag <1 s, secondary chỉ đọc, promote khi DR (~1 phút) ❌
One-line summaryChốt 1 câu Memcached: "RAM + key-value, don't ask me to think." Redis: "Give it here, I'll handle the logic." Memcached: "RAM + key-value, đừng bắt tôi nghĩ." Redis: "Đưa đây, để tôi xử lý."

Common patternsPattern hay dùng

Cache-asideCache-aside App reads cache · miss → DB → populateApp đọc cache · miss → DB → nạp
Write-throughWrite-through Write hits DB + cacheGhi vào DB + cache
Write-behindWrite-behind Write to cache, DB asyncGhi cache, DB async
Session storeSession store Stateless app tier · shared sessionsApp tier stateless · session dùng chung

Sizing extreme ratesƯớc lượng rate cực cao

The design question: what layer can absorb this traffic without hitting the DB? Câu hỏi thiết kế: layer nào hút được traffic mà không chạm DB?

LayerLayer Order of magnitudeCỡ độ lớn
CloudFront250k RPS / distribution (default quota)250k RPS / distribution (quota mặc định)
ALB · API Gateway10k RPS
Lambda1k concurrent (default, raisable)1k concurrent (mặc định, nâng được)
DynamoDB1M RPS · auto-scale