AWS Certified Developer – Associate / Question #889 of 557

Question #889

A company recently deployed a new serverless payment processing system. Users have reported latency during peak transaction times. The initial analysis identified a single Amazon API Gateway endpoint causing delays. The endpoint integrates with an AWS Lambda function, which communicates with multiple third-party payment gateways and internal AWS services.

How can a developer pinpoint the root cause of the latency using operational best practices?

A

Modify the Lambda function to include detailed logging statements with millisecond-level timestamps before and after each external API call. Deploy the updated Lambda function. After collecting sufficient log data, analyze the Amazon CloudWatch logs to identify the components contributing to the latency.

B

Instrument the Lambda function using the AWS X-Ray SDK. Configure HTTP/HTTPS interceptors and SDK client handlers. Deploy the updated Lambda function. Enable X-Ray tracing. After gathering enough data, analyze the X-Ray service map to review segment durations and identify latency sources.

C

Examine the Lambda function's Amazon CloudWatch metrics using the metrics dashboard. Apply anomaly detection to the Duration and ConcurrentExecutions metrics. Investigate the anomalies to determine potential causes of the latency.

D

Create an Amazon CloudWatch Synthetics canary with X-Ray tracing enabled. Configure the canary to simulate user transactions on the payment system. After collecting sufficient data, use the CloudWatch Synthetics dashboard to analyze latency metrics from the canary.

Explanation

Answer B is correct because AWS X-Ray is specifically designed to trace requests across distributed applications, including Lambda functions and external HTTP/HTTPS calls. By instrumenting the Lambda function with the X-Ray SDK, developers can visualize the entire transaction flow in the X-Ray service map, identify which components (e.g., third-party payment gateways or internal AWS services) contribute to latency, and analyze segment durations. This method provides granular insights into performance bottlenecks.

Other options are less effective:
- A: Manual logging with timestamps is error-prone and time-consuming to analyze.
- C: CloudWatch metrics like Duration and ConcurrentExecutions lack granularity to pinpoint specific external calls.
- D: CloudWatch Synthetics focuses on simulating user traffic rather than diagnosing latency in actual transactions.

Key Points:
1. Use AWS X-Ray for tracing distributed serverless architectures.
2. X-Ray service maps and segments help isolate latency sources.
3. Operational best practices prioritize automated tracing over manual logging or basic metrics.

Answer

The correct answer is: B