☁︎SAA-C03

ElastiCache

ElastiCache — Concept

What it is

Amazon ElastiCache = managed in-memory data store. Two engines: Redis (now "Valkey / Redis OSS-compatible") and Memcached. Used as a cache or a real-time data store to offload databases.

Why it exists

RDBMS reads can be slow and expensive; many web apps repeat the same queries. Putting an in-memory layer in front gives sub-ms latency and reduces DB load and cost.

Engines comparison (exam favorite)

FeatureRedis (OSS / Valkey)Memcached
Data structuresStrings, hashes, lists, sets, sorted sets, streams, geo, hyperloglogStrings only
PersistenceSnapshots + AOF (optional)None (cache only)
Replication / HAYes — Multi-AZ, automatic failoverNo replication
Pub/Sub & StreamsYesNo
Transactions / LuaYesNo
Cluster mode (sharded)YesYes (no replication)
UseCache + real-time store, sessions, leaderboards, queuesPure ephemeral cache, multi-thread scale-out

Architectures

  • Redis (cluster mode disabled) = 1 primary + up to 5 replicas, Multi-AZ.
  • Redis (cluster mode enabled) = up to 500 shards, each with its own primary + replicas.
  • Memcached = pool of nodes, app-side hash partitioning.

Caching strategies (commonly tested)

StrategyHow
Lazy loading (cache-aside)App reads cache; on miss, read DB, write cache. Simple, can serve stale.
Write-throughApp writes both cache and DB. Cache always fresh, but extra write latency.
Time-to-live (TTL)Set expiration so stale data drops automatically.

Use cases

  • Database query cache → drop ms→µs.
  • Session store for stateless web tier.
  • Leaderboards (Redis sorted sets).
  • Rate limiting / counters.
  • Pub/sub messaging (Redis).
  • Geospatial queries (Redis).

Security

  • VPC SG (Redis default 6379, Memcached 11211).
  • Redis: AUTH password, encryption in transit & at rest, RBAC.
  • Memcached: no encryption/auth historically (newer versions add some).

When to use vs alternatives

Use ...Instead of ...When ...
RedisMemcachedNeed HA, persistence, advanced data structures
MemcachedRedisSimple cache, multi-threaded scale-out, you don't care about persistence
DAXElastiCacheDynamoDB is the backing store
DynamoDBElastiCachePersistent key-value DB, not just cache
MemoryDB for RedisElastiCache RedisNeed Redis API as a durable primary DB (Multi-AZ transactional log)

Common exam scenarios

  1. "Stateless web tier needs session storage"ElastiCache Redis (HA + persistence).
  2. "Cache DB query results, sub-ms reads"ElastiCache.
  3. "Real-time leaderboard for game"Redis sorted sets.
  4. "Pure ephemeral cache, multi-thread scale-out"Memcached.
  5. "Acceleration for DynamoDB reads"DAX, not ElastiCache.
  6. "Redis as primary durable DB"MemoryDB for Redis.

Exam tip

Whenever you see "sub-millisecond reads", "reduce DB load", "session store", "leaderboard", "rate limiter" → think ElastiCache (Redis). For DynamoDB workloads → DAX.

References