DVA-C02 · Question #346
A company recently deployed a new serverless user portal. Users have reported that part of the portal is slow. The initial analysis found a single Amazon API Gateway endpoint that is responsible for…
The correct answer is B. Instrument the Lambda function with the AWS X-Ray SDK. Add HTTP and HTTPS interceptors. AWS X-Ray with HTTP/HTTPS interceptors traces every downstream API and AWS service call inside a Lambda function, pinpointing which external call is causing latency.
Question
A company recently deployed a new serverless user portal. Users have reported that part of the portal is slow. The initial analysis found a single Amazon API Gateway endpoint that is responsible for the performance issues. The endpoint integrates with an AWS Lambda function. However, the Lambda function interacts with other APIs and AWS services. How can a developer find the source of the increased response time by using operational best practices?
Options
- AUpdate the Lambda function by adding logging statements with high-precision timestamps before
- BInstrument the Lambda function with the AWS X-Ray SDK. Add HTTP and HTTPS interceptors
- CReview the Lambda function's Amazon CloudWatch metrics by using the metrics explorer. Apply
- DUse Amazon CloudWatch Synthetics to create a new canary. Turn on AWS X-Ray tracing on the
How the community answered
(35 responses)- A6% (2)
- B51% (18)
- C14% (5)
- D29% (10)
Why each option
AWS X-Ray with HTTP/HTTPS interceptors traces every downstream API and AWS service call inside a Lambda function, pinpointing which external call is causing latency.
Manual timestamp logging requires identifying which calls to log in advance and produces unstructured data that is difficult to correlate; it also does not provide a visual service map or automatic subsegment breakdown.
Instrumenting the Lambda function with the X-Ray SDK and adding HTTP/HTTPS client interceptors causes the SDK to automatically create subsegments for every outbound HTTP call and AWS SDK call. The resulting trace and flame graph in the X-Ray console shows the exact duration of each downstream call, directly identifying the source of increased response time.
CloudWatch Lambda metrics (duration, errors, invocations) show aggregate function-level performance but cannot isolate which specific downstream API call inside the function is responsible for the slowness.
CloudWatch Synthetics canaries measure end-to-end availability from the outside but do not instrument the Lambda function's internal execution or trace individual downstream calls.
Concept tested: AWS X-Ray SDK instrumentation for Lambda latency analysis
Source: https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-python-patching.html
Community Discussion
No community discussion yet for this question.