A developer is optimizing a mobile news reader application that retrieves article metadata from an Amazon RDS MySQL database. When breaking news occurs, read traffic to the database spikes dramatically, causing latency issues. The article metadata is write-once and read-heavy. The developer wants to implement a caching solution using Amazon ElastiCache to mitigate database load, minimize memory usage by caching only the requested articles, and prevent the cache from running out of space.
Which TWO actions should the developer take to meet these requirements? (Select TWO.)
- Implement a lazy-loading (cache-aside) strategy where the application queries the cache first, and writes to the cache only after a database query on a cache miss.Answer
- Configure a Time to Live (TTL) on the cached keys and use a Least Recently Used (LRU) eviction policy.Answer
- CImplement a write-through caching strategy that automatically writes all new articles to the cache whenever they are added to the database.
- DStore the query results in Systems Manager Parameter Store and enable automatic rotation of the cached values.
- EDeploy Amazon DynamoDB Accelerator (DAX) to cache the SQL query results and automatically evict cold data.
Answer
To optimize the database queries while minimizing cache memory, the developer must implement a lazy-loading (cache-aside) caching strategy and configure a Time to Live (TTL) along with an LRU eviction policy.
Implementing a lazy-loading caching strategy is the best choice because the cache is only populated on demand (after a cache miss), which minimizes memory usage. Additionally, configuring a Time to Live (TTL) prevents stale metadata from being served, and using a Least Recently Used (LRU) eviction policy ensures that the least requested items are removed when cache capacity is reached, preventing out-of-memory issues.
Step-by-Step Solution
Key Concept
Selecting and configuring cache strategies (lazy-loading), TTL, and eviction policies using Amazon ElastiCache to reduce relational database load.
Estimated Time:2m 0s