Question #1291
A company hosts a dynamic web application on Amazon EC2 instances behind an Application Load Balancer (ALB) in the eu-west-1 region. Users in different regions report varying latency, especially on mobile devices. The company wants to improve performance globally without replicating the infrastructure across multiple regions. The application serves different content based on the User-Agent header to optimize for mobile or desktop users. What should a solutions architect do to meet these requirements?
Replace the existing architecture with a static website hosted on Amazon S3. Configure an Amazon CloudFront distribution with the S3 bucket as the origin. Set the cache behavior to cache based on the User-Agent request header.
Configure an Amazon CloudFront distribution with the ALB as the origin. Set the cache behavior settings to cache based on the User-Agent request header.
Create an Amazon API Gateway API integrated with the ALB using HTTP integration. Enable API Gateway caching based on the User-Agent header.
Deploy EC2 instances in additional Regions and configure a caching layer using Varnish. Use Amazon Route 53 with a geolocation routing policy to direct traffic.
Explanation
Answer B is correct because:
1. CloudFront's Global CDN: Deploying CloudFront reduces latency by caching content at edge locations closer to users globally, addressing the latency issue without replicating infrastructure.
2. Dynamic Content Support: Using the ALB as the origin allows CloudFront to handle dynamic content from EC2 instances while caching frequently accessed resources.
3. User-Agent Header Caching: Configuring cache behaviors based on the User-Agent header ensures mobile/desktop users receive optimized content, aligning with the application's requirements.
Other options are incorrect because:
- A: Replacing EC2/ALB with S3 assumes the application is static, which contradicts the dynamic nature described.
- C: API Gateway is designed for API management, not CDN caching, and lacks CloudFront's global edge network for latency reduction.
- D: Deploying EC2 in multiple regions violates the requirement to avoid infrastructure replication.
Key Points: Use CloudFront for global caching of dynamic content, leverage existing ALB as the origin, and cache based on headers to optimize user-specific content.
Answer
The correct answer is: B