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

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.