Caching and specialized data stores: DVA-C03 study notes and practice questions
What to know about Caching and specialized data stores for the DVA-C03 exam, from the Development with AWS Services domain (30% of the exam guide), then 1 free question to test it. Part of the DVA-C03 study guide.
Caching questions give you a symptom such as slow reads, stale prices, or a node failure, and ask which cache or store to use and how to keep it consistent with the database. Pick the engine by the feature the scenario needs, then the loading pattern.
ElastiCache engines
Valkey and Redis OSS support replication, automatic failover across Availability Zones, persistence, and data types such as sorted sets. Use them for leaderboards, sessions and carts that must survive a node loss.
Memcached is a simple cache with no replication or persistence. It scales by adding nodes and suits disposable data such as rendered HTML fragments.
Automatic failover needs a replicated setup. A single node cannot fail over.
Loading patterns
Lazy loading (cache-aside): the app reads the cache, and on a miss reads the database and fills the cache. Entries can go stale, so set a TTL.
Write-through: every database write also updates the cache. Reads stay fresh, at the cost of extra writes.
A cache with no TTL and no invalidation keeps old prices after the database changes. Fix it with a TTL, a delete on update, or write-through.
Other stores
DAX is a managed, in-memory cache for DynamoDB. It gives microsecond reads for eventually consistent reads and is the answer when the question says “DynamoDB” and “microsecond.”
Amazon OpenSearch Service handles full-text search, ranking and typo tolerance. Keep DynamoDB for key lookups and use OpenSearch for “find recipes matching these words.”
Amazon Aurora and RDS provide read replicas for read scaling, which is different from a cache.
How to choose
Scenario wording
Answer
Cart must survive a node failure, automatic failover
ElastiCache for Valkey or Redis OSS with replication
Live leaderboard, top N, many reads a second
ElastiCache sorted sets
Disposable fragments, add nodes, multiple cores
ElastiCache for Memcached
Microsecond reads of DynamoDB items
DAX
Free-text search with ranking and typos
OpenSearch Service
Common traps
Memcached for failover or persistence.
Caching without a TTL when the data changes.
DAX for strongly consistent reads. DAX serves eventually consistent reads.
Scanning DynamoDB to build a search feature.
Using a cache as the only copy of data. Keep the source of truth in the database.
A retailer will store shopping carts in Amazon ElastiCache.
A cart must survive the loss of one cache node, and the cache must fail over automatically to a copy in another Availability Zone, so that customers keep their items during a node failure. Cart writes are frequent, and the team wants the simplest configuration that meets these needs.
Which configuration should the developer choose?
Choose one answer.
AA. Memcached, with three nodes spread across Availability Zones and the cart keys divided between them by the client's hashing.
BB. Redis OSS in cluster mode disabled, with a replica in another Availability Zone and automatic failover turned on.
CC. Redis OSS in cluster mode enabled, with one shard and no replicas, so that every cart is stored on a single node.
DD. Redis OSS with one primary and no replicas, plus an hourly snapshot that can be restored into a new cluster if the node fails.
C. Wrong: With no replica there is nothing to fail over to. Losing the node loses the carts stored on it, and the cache is unavailable until a replacement node is ready.
D. Wrong: Snapshots help you restore data after a failure, but they do not provide automatic failover. Customers would see an outage until the restore is complete.
Explanation
Replication and automatic failover are what let a cache survive a node failure. Memcached has neither. Redis OSS has both, so a replica in another Availability Zone, with automatic failover turned on, takes over when the primary fails and the cart data is kept.
Want more on Caching and specialized data stores? The 5 full-length practice sets have 5 more Caching and specialized data stores questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →