Skip to content

9 · Database & Caching Performance — Revise

Performance · 24% · Compressed recall. Read the Learn guide first.

Database pick

Need Choose
Joins, transactions, SQL, existing relational RDS / Aurora
Massive scale, key-value/document, single-digit-ms, serverless DynamoDB
Analytics / data warehouse Redshift
Scale RDS reads Read replicas
Serverless connection storms on RDS RDS Proxy (pooling)

Which cache

Cache Fronts Use
DAX DynamoDB Microsecond reads, API-compatible
ElastiCache Relational / app / sessions Offload repeated reads, session store
CloudFront Web content at edge Global low-latency delivery

Redis vs Memcached

Redis Memcached
HA / replication ✅ Multi-AZ, failover
Persistence / backup
Data types Rich (sorted sets, pub/sub) Simple key-value
Pick when HA, durability, leaderboards, sessions Simple multi-threaded ephemeral cache
DynamoDB microsecond reads?      → DAX
Cache relational query results?  → ElastiCache (Redis if HA/persistence)
Global content delivery?         → CloudFront
Make app stateless (sessions)?   → ElastiCache / DynamoDB

Flashcards

Microsecond reads for DynamoDB — which cache? DAX (DynamoDB-native, API-compatible). NOT ElastiCache.
Cache in front of a relational DB with HA + failover? ElastiCache for Redis.
Redis vs Memcached — which has replication/persistence? Redis. Memcached is a simple, multi-threaded, non-persistent cache.
Millions of req/s, key-value, single-digit-ms, serverless? DynamoDB.
Global images/videos served slowly — fix? CloudFront (edge caching).
Lambda functions exhausting RDS connections? RDS Proxy (connection pooling).
Users logged out across instances behind an ELB — scalable fix? Store sessions in ElastiCache/DynamoDB → stateless app.
Lazy loading vs write-through? Lazy loading: cache on miss (only requested data cached, can be stale). Write-through: write cache+DB together (always fresh, may cache unused data).

Common traps

  • DAX = DynamoDB; ElastiCache = relational/app; CloudFront = edge content. Don't swap.
  • Redis = HA/persistence/rich types; Memcached = simple ephemeral.
  • Relational (joins/transactions) → RDS/Aurora; key-value at scale → DynamoDB.
  • Read replicas scale reads; caches offload repeated reads — different tools.
  • Sessions → ElastiCache/DynamoDB to enable stateless scaling.
  • RDS Proxy for serverless connection pooling.