Question

Difficulty: HardHigh-Performing Content Delivery and Caching Solutions

A media publishing platform hosts its static assets in an Amazon S3 bucket and distributes them globally via an Amazon CloudFront distribution. During a high-traffic breaking news event, the Amazon S3 bucket experiences a massive surge in read requests, leading to performance degradation and high costs. An investigation reveals that a developer set the CloudFront cache behavior TTL values to 0 to ensure that readers always receive the most up-to-date images and CSS files. Which solution should a solutions architect implement to resolve the S3 performance issue while ensuring users still receive updated assets immediately?

  1. A
    Configure the CloudFront cache behavior to set the Minimum, Maximum, and Default TTL to 0, forcing CloudFront to forward every client request to the Amazon S3 origin to check for the latest version.
  2. B
    Deploy Amazon EC2 proxy instances in a private subnet to retrieve static assets from Amazon S3 via a NAT Gateway, and configure the application to bypass CloudFront and load assets directly from these EC2 instances.
  3. Configure the CloudFront cache behavior to use a Cache Policy with a long Default TTL (such as 30 days), and update the web application to use a file versioning naming convention (such as appending a unique hash to the asset filenames) whenever an asset is updated.Answer
  4. D
    Transition the static assets in the Amazon S3 bucket to the S3 Standard-Infrequent Access (S3 Standard-IA) storage class to reduce costs, and configure the CloudFront behavior to use a Default TTL of 1 hour, overwriting S3 objects whenever they are updated.

Answer

Configure the CloudFront cache behavior to use a Cache Policy with a long Default TTL and implement file versioning (cache-busting) in the web application for updated assets.
The correct solution uses a combination of long-term CloudFront caching (long TTL Cache Policy) and web application file versioning (cache-busting). By renaming updated assets (e.g., `image_v2.png`), the application changes the request URI. CloudFront treats the new URI as a cache miss, fetches the new version from S3, caches it, and serves subsequent requests from the edge. This guarantees that users receive updates instantly while keeping the cache hit ratio high and S3 read requests minimal.

Step-by-Step Solution

1
Analyze the current issue.
The S3 bucket is overloaded because CloudFront caching is bypassed (TTL = 0), sending all client requests directly to S3.
Understanding the root cause allows us to target the solution to both enable caching and satisfy the requirement for immediate updates.
2
Select the correct caching strategy.
Enable caching by setting a positive TTL (e.g., 30 days) on CloudFront.
Caching static files on the edge protects the S3 origin from traffic spikes and reduces network latency and data transfer costs.
3
Address the requirement for immediate asset updates.
Implement file versioning or cache-busting (e.g., adding a hash or version to filenames) in the web application's asset references.
When a file is modified, the new path forces CloudFront to retrieve and cache the new version instantly, while unchanged assets continue to be served from the edge cache.

Key Concept

CloudFront Caching and File Versioning (Cache-Busting)
Estimated Time:2m 0s
Rate this question