A software developer is building a SaaS dashboard application that runs on an Amazon ECS cluster. The application displays financial exchange rates retrieved from a third-party API. The exchange rates are updated exactly once every hour. To minimize third-party API usage fees and improve application response times, the developer wants to implement a shared caching solution that automatically invalidates stale data after 1 hour. Which solution meets these requirements with the lowest latency?
- Deploy an Amazon ElastiCache for Redis cluster. Implement a cache-aside (lazy-loading) pattern in the application code, and set a Time to Live (TTL) of 3600 seconds on the cached keys.Answer
- BStore the exchange rates in AWS Systems Manager Parameter Store. Configure the application to retrieve the parameters on every request, relying on Parameter Store's API integration for high-throughput caching.
- CSave the exchange rates in an Amazon DynamoDB table. Configure the ECS tasks to run a Scan operation on the table for every user request, relying on DynamoDB's provisioned throughput to serve the cached data.
- DWrite the rates to a local file on a shared Amazon EBS volume. Configure the ECS Task Execution Role to automatically synchronize the file contents across all running container tasks.
Answer
Deploy an Amazon ElastiCache for Redis cluster. Implement a cache-aside (lazy-loading) pattern in the application code, and set a Time to Live (TTL) of 3600 seconds on the cached keys.
The correct solution uses Amazon ElastiCache for Redis to store the exchange rates. The cache-aside (lazy-loading) pattern checks the cache first, loads from the third-party API only on a cache miss, and writes the retrieved rate back to the cache. Setting a Time to Live (TTL) of 3600 seconds ensures that the cache automatically invalidates its data after one hour, prompting a refresh when the next request occurs. This approach ensures sub-millisecond response times and minimizes third-party API costs.
Step-by-Step Solution
Key Concept
Using Amazon ElastiCache with a cache-aside pattern and TTL configuration is the standard architectural pattern for low-latency, shared application caching in AWS.
Estimated Time:1m 30s