SAA-C03 ยท High-performing databases and caching
Caching patterns: lazy loading, write-through, TTL and DAX
Lazy loading versus write-through, TTLs, ElastiCache for Redis OSS, Valkey or Memcached, and DynamoDB Accelerator (DAX) for microsecond reads.
Key points
- ElastiCache: in-memory cache before a DB (Valkey, Redis OSS, Memcached).
- Lazy loading: on a miss, query DB and fill cache; only requested data, 3 trips per miss; can go stale.
- Write-through: DB writes update cache; fresh, but new nodes empty, unread data wastes memory (cache churn).
- TTL expires keys, bounds staleness; common with lazy loading.
- DAX: DynamoDB API-compatible cache, eventually consistent reads in microseconds.
Source: https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/Strategies.html
Practice questions
Which caching strategy puts data into the cache only after a cache miss, when the application has fetched it from the database?
- Write-through
- Lazy loading
- Write-behind batching
- Cache pre-warming at deploy
Show answer
Answer: B. Lazy loading
Lazy loading fills the cache on demand after a miss, so only requested data is cached. Write-through writes to the cache on every database write, whether or not the data is ever read.
Which of these are drawbacks of the write-through caching strategy?
- Data that is written but never read wastes cache memory
- Keys written this way cannot be given a TTL
- Cached data goes stale when the database is updated
- Every cache miss costs three separate round trips
- A new cache node is missing data until that data is written again
Show answer
Answer: A. Data that is written but never read wastes cache memory, E. A new cache node is missing data until that data is written again
With write-through, a new or replaced node lacks data until it is written again, and data that is written but never read wastes cache memory (cache churn). Stale data and the three-trip miss penalty are drawbacks of lazy loading, and write-through can be combined with a TTL.
DynamoDB Accelerator (DAX) is a good fit for an application that cannot tolerate anything but strongly consistent reads.
Show answer
Answer: False
False. DAX serves eventually consistent data from memory with microsecond latency. Applications that require strongly consistent reads are listed as a poor fit, as are write-heavy workloads with few repeated reads.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
