DVA-C02 practice question 31 of 35

A company runs an ecommerce application on AWS. The application stores data in an Amazon Aurora database. A developer is adding a caching layer to the application. The caching strategy must ensure that the application always uses the most recent value for each data item. Which caching strategy will meet these requirements?

Full set: 598 questions

Domain Troubleshooting and Optimization

Answer options
A: Implement a TTL strategy for every item that is saved in the cache.
B: Implement a write-through strategy for every item that is created and updated. Correct answer
C: Implement a lazy loading strategy for every item that is loaded.
D: Implement a read-through strategy for every item that is loaded.
Correct Answer:
B. Implement a write-through strategy for every item that is created and updated.
Explanation

The write-through caching strategy ensures data consistency by writing data into the cache and the backing database at the same time. This approach guarantees that any data written to the database is immediately reflected in the cache. Consequently, any subsequent read from the cache will retrieve the most recent value, fulfilling the strict requirement that the application always uses the most up-to-date data. This strategy prioritizes data freshness over write latency.

Why Incorrect

A. A Time-To-Live (TTL) strategy evicts data after a set period, but it allows for a window of time where the cache can hold stale data if the database is updated before the TTL expires.
C. A lazy loading (or cache-aside) strategy only populates the cache when a read request results in a cache miss. It does not update the cache when data is written to the database, leading to stale data.
D. A read-through strategy is similar to lazy loading, where the cache is responsible for loading data from the database on a miss. It does not address how the cache is updated upon a write operation. ---

References

1. AWS ElastiCache User Guide

"Caching strategies": The documentation explicitly describes the write-through strategy: "The write-through strategy adds data or updates data in the cache whenever data is written to the database. This keeps the cache data from being stale." It also notes that lazy loading can result in stale data.

Source: AWS ElastiCache User Guide

Section: "In-Memory Caching" -> "Caching strategies".

2. AWS Well-Architected Framework

Performance Efficiency Pillar Whitepaper (July 2023): This paper discusses caching patterns. In the section "PER 8: How do you select your database solution?"

it describes caching as a technique to improve performance. The principles discussed align with write-through being the method to ensure data consistency between the cache and the database.

Source: AWS Well-Architected Framework

Performance Efficiency Pillar

Page 41

under "Caching".

3. AWS Blog

"Caching Best Practices": Multiple AWS blog posts detail caching patterns. They consistently describe write-through as the appropriate pattern when the primary requirement is to prevent stale data reads

as it synchronizes writes to both the cache and the primary database.

Source: AWS Architecture Blog

"Caching Patterns and Best Practices". (Note: Specific blog post titles may vary

but the content on this topic is consistent across official AWS blogs).

Scroll to Top