Question

Difficulty: MediumHigh-Performing Content Delivery and Caching Solutions

A company hosts a content-heavy financial news website on AWS using an Application Load Balancer (ALB) and an Auto Scaling group of Amazon EC2 instances as the origin. To reduce latency for its global audience, the company configured an Amazon CloudFront distribution. However, during peak traffic, the EC2 instances experience high CPU utilization due to a massive volume of requests for static images and stylesheets, causing slow page loads. A solutions architect reviews the CloudFront configuration and finds that the cache behavior for static assets has the Minimum TTL, Default TTL, and Maximum TTL all set to 0. Which configuration change should the solutions architect implement to resolve the performance issue on the origin EC2 instances?

  1. A
    Keep the TTL values at 0 in CloudFront to ensure content freshness, but enable CloudFront Origin Shield to cache the static assets at a centralized regional layer.
  2. B
    Migrate the static assets to an Amazon Elastic File System (EFS) volume mounted on all EC2 instances, and configure Provisioned Throughput to handle the high IOPS demands, while leaving the CloudFront TTL settings at 0.
  3. Modify the static assets cache behavior to set the Minimum, Default, and Maximum TTLs to non-zero values, allowing CloudFront to serve the static content from edge caches without forwarding validation requests to the ALB.Answer
  4. D
    Move the static assets to an Amazon S3 bucket, and route all data transfer from the EC2 instances to the S3 bucket through a NAT Gateway to ensure low-latency delivery to CloudFront, while keeping the CloudFront TTL settings at 0.

Answer

Modify the static assets cache behavior to set the Minimum, Default, and Maximum TTLs to non-zero values, allowing CloudFront to serve the static content from edge caches without forwarding validation requests to the ALB.
Modifying the cache behavior for static assets to use non-zero TTL values allows Amazon CloudFront to cache static files at edge locations. Once cached, subsequent requests from users are served directly from the edge cache, eliminating the need to forward validation requests to the origin Application Load Balancer and significantly reducing origin CPU utilization.

Step-by-Step Solution

1
Identify the cause of origin CPU spikes and slow page load times.
The CloudFront cache behavior for static assets has Minimum, Default, and Maximum TTLs all set to 0.
A TTL of 0 prevents CloudFront from caching content at edge locations, forcing it to forward every request to the origin for validation, which overloads the ALB and EC2 instances.
2
Determine the correct caching configuration for static content.
Change the TTL settings in the cache behavior for static assets to non-zero values (e.g., Default TTL = 86400).
This allows CloudFront to cache the static assets at edge locations and serve them directly to clients, preventing requests from hitting the origin servers.
3
Evaluate and rule out sub-optimal solutions such as adding EFS provisioned throughput or routing through NAT Gateways.
Alternative solutions either do not resolve the lack of caching at the edge or introduce unnecessary costs and architectural complexity.
Caching at the edge is the standard best practice for optimizing static asset delivery and reducing origin load.

Key Concept

Configuring CloudFront TTL values to enable effective edge caching and reduce origin request load.
Estimated Time:1m 30s
Rate this question