Soru

Zorluk: OrtaApplication Caching and Session State Management

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?

  1. 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.Cevap
  2. B
    Store 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.
  3. C
    Save 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.
  4. D
    Write 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.

Cevap

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.

Adım Adım Çözüm

1
Identify the caching requirements: shared cache across multiple ECS container instances, automatic expiration after 1 hour (3600 seconds), and low-latency retrieval.
Requires a central, high-performance in-memory key-value store with TTL support.
Since the ECS tasks are distributed, local memory caches would become inconsistent, and direct third-party API calls must be minimized.
2
Evaluate Amazon ElastiCache for Redis as the central cache store with a cache-aside strategy.
ElastiCache provides sub-millisecond latency. A TTL of 3600 seconds ensures that keys automatically expire 1 hour after they are written, prompting the application to fetch fresh data on the next request.
This directly satisfies the invalidation requirement and ensures that the third-party API is only called once per hour per rate key.
3
Rule out alternative options that use improper AWS services or anti-patterns.
Parameter Store is for configuration/secrets; DynamoDB Scan is inefficient for high-read caching; ECS Task Execution Role cannot synchronize local EBS file storage.
These alternatives violate AWS best practices for application caching and performance optimization.

Anahtar Kavram

Using Amazon ElastiCache with a cache-aside pattern and TTL configuration is the standard architectural pattern for low-latency, shared application caching in AWS.
Tahmini Süre:1m 30s
Bu soruyu puanla