How to measure custom Lambda throughput excluding initialization in CloudWatch?
A company's application has an AWS Lambda function that processes messages from IoT devices. The company wants to monitor the Lambda function to ensure that the Lambda function is meeting its required service level agreement (SLA). A developer must implement a solution to determine the application's throughput in near real time. The throughput must be based on the number of messages that the Lambda function receives and processes in a given time period. The Lambda function performs initialization and post-processing steps that must not factor into the throughput measurement. What should the developer do to meet these requirements?
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
This question tests the ability to define and measure custom business-level throughput in Lambda by emitting CloudWatch metrics at specific code points, avoiding reliance on default metrics that include all execution phases.
To measure AWS Lambda throughput excluding initialization and post-processing time, developers must publish custom Amazon CloudWatch metrics at the exact points messages are received and processed. Community consensus strongly supports custom metrics for precise, near real-time SLA monitoring.
Candidates often choose option D, using the built-in Invocations and Duration metrics, mistakenly believing they can derive throughput from them. However, Duration includes initialization and post-processing time, which the requirement explicitly excludes.
Community Discussion (7 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Understanding the Requirement
The scenario requires measuring throughput defined strictly as the number of messages received and processed by a Lambda function within a time period, explicitly excluding initialization and post-processing steps. This is a custom business metric, not a standard AWS operational metric.
Why Option C is Correct
Option C instructs the developer to modify the Lambda function code to publish custom Amazon CloudWatch metrics using the AWS SDK (e.g., boto3 put_metric_data) precisely when a message is received and again when it is successfully processed. This approach:
- Provides near real-time visibility because CloudWatch custom metrics can be emitted with a resolution of 1 second (high-resolution metrics) or 1 minute.
- Allows the developer to isolate the exact processing window by placing metric emission calls immediately before and after the core processing logic, completely bypassing initialization and post-processing phases.
- Enables throughput calculation as the delta between received and processed counts over a defined time window.
MessagesProcessed custom metric inside the handler.Why the Other Options Are Incorrect
- Option A (ConcurrentExecutions metric): This metric indicates how many instances of the function are running concurrently. It reflects scaling behavior, not message throughput, and cannot distinguish between initialization, processing, or post-processing phases.
- Option B (CloudWatch Logs + EventBridge + separate Lambda): While technically feasible, this introduces unnecessary latency and complexity. Parsing logs on a schedule does not meet the near real-time requirement and adds operational overhead compared to direct custom metric emission.
- Option D (Invocations and Duration metrics): The built-in
Invocationsmetric counts total invocations, andDurationmeasures total execution time from start to finish, including initialization (cold starts) and post-processing. Since the requirement explicitly excludes these phases, these default metrics cannot accurately reflect the desired throughput definition. Community comment [5] emphasizes that because the question provides its own definition of throughput, custom metrics are mandatory.
Key Takeaway
Whenever an exam question defines a custom business metric that does not align 1:1 with AWS default metrics—especially when specific execution phases must be included or excluded—the correct approach is almost always to publish custom CloudWatch metrics from within the application code.
Official Reference
Exam Strategy
When a question defines its own metric or measurement criteria that differs from AWS default metrics, immediately look for the option involving custom metrics or application-level instrumentation. Default CloudWatch metrics rarely satisfy custom business SLA definitions.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →