AWS Certified Developer – Associate — Question 153
A developer creates a web service that performs many critical activities. The web service code uses an AWS SDK to publish noncritical metrics to Amazon CloudWatch by using the PutMetricData API. The web service must return results to the caller as quickly as possible. The response data from the PutMetricData API is not necessary to create the web service response.
Which solution will MOST improve the response time of the web service?
Answer options
- A. Upgrade to the latest version of the AWS SDK.
- B. Call the PutMetricData API in a background thread.
- C. Use the AWS SDK to perform a synchronous call to an AWS Lambda function. Call the PutMetricData API within the Lambda function.
- D. Send metric data to an Amazon Simple Queue Service (Amazon SQS) queue. Configure an AWS Lambda function with the queue as the event source. Call the PutMetricData API within the Lambda function.
Correct answer: D
Explanation
Option D is the best choice because it offloads the metric publishing to an AWS Lambda function triggered by an SQS queue, allowing the web service to respond quickly without waiting for the PutMetricData API response. Option A does not address the response time issue directly, while option B may still delay the response if the background thread takes time. Option C also introduces some latency by making a synchronous call to the Lambda function, which is not as efficient as using an SQS queue.