A gaming company has a mobile game played by users worldwide. The application retrieves game configuration metadata from an API hosted on Amazon API Gateway and backed by AWS Lambda. The metadata is updated once daily. During peak tournament hours, the Lambda functions experience a high volume of requests, causing concurrency throttling and increased latency for global players. A solutions architect needs to design a caching solution to reduce the load on the Lambda functions and minimize response latency for players globally. Which solution will meet these requirements with the lowest latency for global players?
- Create a custom Amazon CloudFront distribution with a regional API Gateway stage as the origin. Enable caching on CloudFront using a cache policy with a 24-hour TTL, and update the DNS record for the custom domain to point to the CloudFront distribution.Answer
- BCreate a custom Amazon CloudFront distribution with a regional API Gateway stage as the origin. Configure the cache behavior's Minimum TTL, Default TTL, and Maximum TTL to 0 to ensure players always receive the most up-to-date configuration metadata directly from the origin.
- CMigrate the metadata storage to an Amazon DynamoDB table using a sequential timestamp as the partition key to optimize query performance, and enable DynamoDB Accelerator (DAX) to cache the queries.
- DWrite an AWS Lambda function that runs continuously in a loop to handle the high volume of incoming player requests, caching the configuration in the Lambda function's memory, and route traffic using a NAT Gateway.
Answer
Create a custom Amazon CloudFront distribution with a regional API Gateway stage as the origin. Enable caching on CloudFront using a cache policy with a 24-hour TTL, and update the DNS record for the custom domain to point to the CloudFront distribution.
The correct solution uses an Amazon CloudFront distribution to cache game configuration metadata at edge locations globally. Because the metadata is updated only once per day, caching the response for 24 hours at the edge ensures that almost all requests are served from the cache, reducing backend Lambda invocations to a minimum and lowering player response times to sub-milliseconds. Directing custom domain traffic to CloudFront preserves the client endpoint configuration.
Step-by-Step Solution
Key Concept
Edge caching using Amazon CloudFront in front of regional API endpoints protects compute resources and minimizes latency for global clients.
Estimated Time:2m 0s