How to find the source of increased response time in a Lambda function integrated with API Gateway?
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?
Community Votes
83% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The core concept is distributed tracing; the common trap is confusing proactive monitoring (CloudWatch Synthetics canaries) with reactive performance debugging (AWS X-Ray).
This question tests the use of AWS X-Ray to trace and identify performance bottlenecks in a serverless application where a Lambda function interacts with multiple external services. The community strongly agrees that instrumenting the Lambda function with the X-Ray SDK and analyzing the service map is the operational best practice for pinpointing increased response times.
Many candidates choose Option D (CloudWatch Synthetics canary) because it sounds like a modern monitoring solution, but canaries are designed for proactive availability and latency monitoring from the outside, not for deep-diving into the internal execution segments of a Lambda function to find which downstream call is slow.
Community Discussion (6 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Understanding the Problem
The scenario describes a serverless user portal where a specific Amazon API Gateway endpoint is slow. This endpoint triggers an AWS Lambda function that, in turn, calls other APIs and AWS services. The developer's goal is to find the source of the increased response time using operational best practices. This is a classic distributed tracing problem.
Why Option B is Correct
AWS X-Ray is AWS's dedicated distributed tracing service. It is specifically designed to help developers analyze and debug production, distributed applications, such as those built using a microservices or serverless architecture. By instrumenting the Lambda function with the AWS X-Ray SDK and adding interceptors for HTTP/HTTPS calls and SDK client handlers, X-Ray can trace the entire request path.
When you turn on X-Ray tracing and analyze the X-Ray service map, you can visually see the entire workflow and the average response times for each downstream call (the other APIs and AWS services). This allows you to instantly pinpoint which specific external dependency is causing the latency. As community member Saudis noted, "increased response => Tracing so B is the best choice."
Why the Other Options are Incorrect
- Option A (Custom Logging): While adding custom logs with high-precision timestamps in Amazon CloudWatch Logs can technically help calculate durations, it is a manual, error-prone, and inefficient process. It is not considered an "operational best practice" for distributed systems when a purpose-built tool like X-Ray exists. You would have to manually correlate log entries across multiple requests to find the bottleneck.
Duration and Throttles) provide an aggregate view of the function's performance. While anomaly detection is a great feature for alerting you that the duration has increased, it will not tell you why it increased or which* downstream call is responsible. It lacks the granular, segment-level detail required for this task.
Option D (CloudWatch Synthetics): This is the most common trap. Amazon CloudWatch Synthetics uses canaries to proactively monitor the availability and latency of your endpoints from the outside. While it can tell you that the portal is slow, it does not provide the internal, segment-by-segment breakdown of the Lambda function's execution. As community member DeaconStJohn* correctly pointed out, canaries are better for capturing issues before customers see them, not for debugging the internal cause of an already reported performance issue.Key Takeaway
When the question asks to find the source of latency in a distributed application (like a Lambda function calling multiple services), the answer is almost always AWS X-Ray. It provides the necessary service map and trace details to see exactly where the time is being spent.
Official Reference
Exam Strategy
When an AWS exam question asks to 'find the source' of a problem in a distributed or serverless application, look for the distributed tracing service (AWS X-Ray). Distinguish between tools that alert you to a problem (CloudWatch Alarms, Synthetics) and tools that help you debug the root cause internally (X-Ray).
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →