AWS Developer Associate · Domain 4 of 4 · 18% of the exam

AWS Developer Associate Domain 4: Troubleshooting and Optimization

37 free practice questions for Troubleshooting and Optimization in the AWS Certified Developer – Associate (DVA-C02) exam. Try each question first, then open "Show answer" for the correct option and explanation.

Troubleshooting and Optimization practice questions

  1. Question 1. Which service traces a request across API Gateway, Lambda, and DynamoDB to show where latency occurs?

    1. AWS CloudTrail
    2. AWS Config
    3. Amazon Inspector
    4. AWS X-Ray
    Show answer

    Answer: D. AWS X-Ray

    X-Ray builds a service map from segments and subsegments recorded along the request path.

  2. Question 2. How is X-Ray tracing turned on for a Lambda function?

    1. Install the X-Ray daemon inside the deployment package
    2. Enable active tracing on the function
    3. Add an X-Ray layer to every caller
    4. Create an X-Ray VPC endpoint
    Show answer

    Answer: B. Enable active tracing on the function

    Lambda runs the X-Ray daemon for you. The function's role needs permission to send traces.

  3. Question 3. An application on EC2 uses the X-Ray SDK, but no traces appear. What is commonly missing?

    1. An API Gateway stage in front of the instance
    2. The X-Ray daemon on the instance, allowed to send traces
    3. A CloudFormation stack that enables X-Ray for the account
    4. A Lambda layer installed on the instance's operating system
    Show answer

    Answer: B. The X-Ray daemon on the instance, allowed to send traces

    The SDK sends segments over UDP to the daemon, which uploads them to X-Ray.

  4. Question 4. Developers want to filter X-Ray traces by customer ID. How should the ID be recorded?

    1. As metadata
    2. As an annotation
    3. As a log group name
    4. As a sampling rule name
    Show answer

    Answer: B. As an annotation

    Annotations are indexed for filter expressions. Metadata is stored but not searchable.

  5. Question 5. Why does X-Ray not record every request by default?

    1. Sampling rules limit how many requests are traced to control cost
    2. X-Ray only traces failed requests
    3. X-Ray only traces requests over 1 second
    4. Each service can send only one trace per minute
    Show answer

    Answer: A. Sampling rules limit how many requests are traced to control cost

    The default rule records the first request each second plus 5% of the rest. Rules can be customized.

  6. Question 6. Which open-source option lets an app send traces to X-Ray while staying vendor-neutral?

    1. The CloudWatch Logs agent only
    2. AWS CloudTrail Lake
    3. AWS Distro for OpenTelemetry (ADOT)
    4. Amazon Managed Grafana alone
    Show answer

    Answer: C. AWS Distro for OpenTelemetry (ADOT)

    ADOT collects OpenTelemetry traces and metrics and can export them to X-Ray and CloudWatch.

  7. Question 7. A developer must find the 10 slowest Lambda invocations in the last hour from logs. Which tool fits?

    1. CloudTrail event history
    2. CloudWatch Logs Insights
    3. AWS Config advanced queries
    4. S3 Select
    Show answer

    Answer: B. CloudWatch Logs Insights

    Logs Insights queries the REPORT lines, for example sorting by @duration.

  8. Question 8. An application must publish a custom metric, such as orders per minute, to CloudWatch. Which API is used?

    1. PutMetricData
    2. PutLogEvents
    3. PutEvents
    4. PutTraceSegments
    Show answer

    Answer: A. PutMetricData

    Custom metrics can have dimensions and standard or high resolution.

  9. Question 9. A Lambda function should emit custom metrics without extra API calls. What can it use?

    1. The CloudWatch embedded metric format in its logs
    2. A PutMetricData call on every single invocation
    3. An X-Ray annotation recorded for each metric
    4. A DynamoDB table that stores the metric values
    Show answer

    Answer: A. The CloudWatch embedded metric format in its logs

    CloudWatch extracts metrics from structured EMF log lines asynchronously.

  10. Question 10. Which metric shows that a Lambda function is being rejected because of concurrency limits?

    1. Throttles
    2. Errors
    3. Duration
    4. IteratorAge
    Show answer

    Answer: A. Throttles

    Throttled invocations return 429 errors for synchronous calls. Raise concurrency or reduce load.

  11. Question 11. A Lambda function reading a Kinesis stream falls behind. Which metric shows this?

    1. ConcurrentExecutions
    2. Throttles
    3. IteratorAge
    4. Invocations
    Show answer

    Answer: C. IteratorAge

    IteratorAge is the age of the last record processed. Rising values mean the consumer is lagging.

  12. Question 12. An API Gateway endpoint backed by a Lambda proxy integration returns 502 Bad Gateway. What is a likely cause?

    1. The API key is missing from the request headers
    2. The client exceeded the usage plan's daily quota
    3. The function returned a response in the wrong proxy format
    4. The request was not authorized by the IAM policy
    Show answer

    Answer: C. The function returned a response in the wrong proxy format

    The proxy response must include statusCode and a string body. Unhandled errors also cause 502s.

  13. Question 13. A REST API returns 504 errors for requests that take about 35 seconds. What is the cause?

    1. The Lambda function hit its 15-minute maximum limit
    2. The usage plan's daily request quota was reached
    3. The integration exceeded API Gateway's 29-second timeout
    4. CORS is not enabled on the method being called
    Show answer

    Answer: C. The integration exceeded API Gateway's 29-second timeout

    Long-running work should be made asynchronous, for example by queuing it and returning an ID.

  14. Question 14. Clients of an API Gateway API receive 429 Too Many Requests. What does this mean?

    1. The request was throttled by API Gateway or Lambda
    2. The API key sent with the request was invalid
    3. The backend integration returned an error
    4. The request body was malformed or too large
    Show answer

    Answer: A. The request was throttled by API Gateway or Lambda

    Throttling comes from stage, method, usage plan, or account limits. Clients should retry with backoff.

  15. Question 15. A Lambda function has plenty of memory but is CPU-bound and slow. What is the fix?

    1. Increase only the function's timeout setting
    2. Add more reserved concurrency to the function
    3. Increase the memory setting, which also adds CPU
    4. Move the function's code into a Lambda layer
    Show answer

    Answer: C. Increase the memory setting, which also adds CPU

    Lambda allocates CPU in proportion to memory. More memory can reduce duration and even total cost.

  16. Question 16. How can a developer find the most cost-effective memory setting for a Lambda function?

    1. Test several settings, e.g. with Lambda Power Tuning
    2. Always use the minimum setting of 128 MB
    3. Always use the maximum setting of 10 GB
    4. Set memory equal to the deployment package size
    Show answer

    Answer: A. Test several settings, e.g. with Lambda Power Tuning

    Power Tuning runs the function at several memory sizes and compares speed and cost.

  17. Question 17. Which CloudWatch feature shows Lambda memory usage, CPU time, and cold starts per invocation?

    1. CloudTrail data events
    2. AWS Trusted Advisor
    3. CloudWatch Lambda Insights
    4. VPC Flow Logs
    Show answer

    Answer: C. CloudWatch Lambda Insights

    Lambda Insights uses an extension layer to collect system-level metrics.

  18. Question 18. A function's logs are hard to search because each line is free text. What improves troubleshooting?

    1. Logging less often, and only on successful requests
    2. Structured JSON logs with fields such as requestId
    3. Writing log files to /tmp instead of to stdout
    4. Disabling retention on the function's log group
    Show answer

    Answer: B. Structured JSON logs with fields such as requestId

    Structured logs can be filtered and queried by field in Logs Insights.

  19. Question 19. Lambda log groups keep growing, increasing storage costs. What should be set?

    1. A larger function timeout
    2. A DynamoDB TTL on the logs
    3. Provisioned concurrency
    4. A retention period on the log groups
    Show answer

    Answer: D. A retention period on the log groups

    Log groups keep data forever by default. Set retention to what compliance requires.

  20. Question 20. An alarm should notify the team when a Lambda function's error rate exceeds 5%. What should be created?

    1. A CloudTrail trail filtered on Lambda management events
    2. An X-Ray sampling rule that records only failed requests
    3. A CloudWatch alarm with metric math on Errors and Invocations
    4. An EventBridge rule that matches the function's code updates
    Show answer

    Answer: C. A CloudWatch alarm with metric math on Errors and Invocations

    Metric math divides errors by invocations, and the alarm action publishes to SNS.

  21. Question 21. Which metric shows that messages are waiting too long in an SQS queue?

    1. ApproximateAgeOfOldestMessage
    2. NumberOfMessagesSent
    3. SentMessageSize
    4. NumberOfEmptyReceives
    Show answer

    Answer: A. ApproximateAgeOfOldestMessage

    A rising age means consumers can't keep up. Scale consumers or fix processing errors.

  22. Question 22. An SQS queue shows many NumberOfEmptyReceives, raising cost. What reduces this?

    1. Increase the queue's message retention period
    2. Switch the standard queue to a FIFO queue
    3. Lower the queue's visibility timeout setting
    4. Enable long polling with a wait time of up to 20 seconds
    Show answer

    Answer: D. Enable long polling with a wait time of up to 20 seconds

    Long polling waits for messages instead of returning empty responses right away.

  23. Question 23. Messages keep returning to an SQS queue and are processed repeatedly. What is a likely cause?

    1. The queue's delivery delay is set too long
    2. The consumers use long polling on the queue
    3. The queue's retention period is too short
    4. The visibility timeout is shorter than processing time
    Show answer

    Answer: D. The visibility timeout is shorter than processing time

    If processing takes longer than the visibility timeout, the message reappears for another consumer.

  24. Question 24. A DynamoDB table throttles although total consumed capacity is well below the provisioned amount. What is the likely cause?

    1. The table uses eventually consistent reads
    2. A hot partition key receiving most requests
    3. Point-in-time recovery is enabled
    4. The table has too many attributes
    Show answer

    Answer: B. A hot partition key receiving most requests

    Spread load with a higher-cardinality key or write sharding, for example a random suffix.

  25. Question 25. Which tool shows which DynamoDB partition keys receive the most traffic?

    1. CloudWatch Contributor Insights for DynamoDB
    2. AWS Config rules evaluated on the table
    3. CloudTrail management events for the table
    4. S3 Storage Lens dashboards for the account
    Show answer

    Answer: A. CloudWatch Contributor Insights for DynamoDB

    Contributor Insights reports the most accessed and most throttled keys.

  26. Question 26. Which service records who called an AWS API, such as who deleted a Lambda function?

    1. AWS CloudTrail
    2. AWS X-Ray
    3. CloudWatch metrics
    4. Amazon CodeGuru Profiler
    Show answer

    Answer: A. AWS CloudTrail

    CloudTrail logs management events with the caller identity, time, and source IP.

  27. Question 27. A Lambda function fails with "Task timed out after 3.00 seconds" when calling an external API. What should be checked first?

    1. The version of the layer attached to the function
    2. The provisioned capacity of the DynamoDB table
    3. The function timeout and the network path to the API
    4. The retention setting of the CloudWatch log group
    Show answer

    Answer: C. The function timeout and the network path to the API

    The default timeout is 3 seconds. In a VPC, a missing NAT route also causes hangs until timeout.

  28. Question 28. An SDK call hangs for a long time before failing, which delays the whole Lambda function. What helps?

    1. Set shorter connection and request timeouts in the SDK
    2. Increase the Lambda function timeout to 15 minutes
    3. Remove retries from the function's event source
    4. Increase the function's ephemeral storage size
    Show answer

    Answer: A. Set shorter connection and request timeouts in the SDK

    Explicit SDK timeouts make calls fail fast so retries or fallbacks can run.

  29. Question 29. How can a developer reduce Lambda cold-start duration for a Java function without provisioned concurrency?

    1. Enable Lambda SnapStart
    2. Increase the function timeout
    3. Add a dead-letter queue
    4. Use reserved concurrency
    Show answer

    Answer: A. Enable Lambda SnapStart

    SnapStart restores initialized snapshots, which cuts startup time for supported runtimes.

  30. Question 30. Which change reduces Lambda initialization time for most runtimes?

    1. Adding more environment variables to the function
    2. Increasing the retention period of its log group
    3. Adding more event source mappings to the function
    4. A small package that loads only the dependencies it needs
    Show answer

    Answer: D. A small package that loads only the dependencies it needs

    Smaller packages download and initialize faster. Lazy-load rarely used libraries.

  31. Question 31. An API returns the same product catalog on most requests, causing load on Lambda and DynamoDB. What reduces load quickly?

    1. Enable API Gateway caching with a suitable TTL
    2. Increase Lambda reserved concurrency
    3. Add a global secondary index
    4. Switch the API to a WebSocket API
    Show answer

    Answer: A. Enable API Gateway caching with a suitable TTL

    Cached responses are served by API Gateway without invoking the backend.

  32. Question 32. Uploads of large files to S3 from an application fail midway on unreliable networks. What should be used?

    1. A single PutObject with a longer timeout
    2. Multipart upload, which retries individual parts
    3. S3 Select on the object
    4. A presigned GET URL
    Show answer

    Answer: B. Multipart upload, which retries individual parts

    Multipart upload is recommended above 100 MB and required above 5 GB.

  33. Question 33. An app receives HTTP 503 Slow Down errors from S3 under very high request rates. What helps?

    1. Retry with backoff and spread requests across more prefixes
    2. Switch the bucket to a single-AZ storage class
    3. Disable versioning on the bucket
    4. Use a presigned URL for every request
    Show answer

    Answer: A. Retry with backoff and spread requests across more prefixes

    S3 scales per prefix, and the SDK retries with backoff automatically.

  34. Question 34. Which CloudWatch Logs feature streams matching log events to a Lambda function in near real time?

    1. A metric filter
    2. A log group retention setting
    3. Logs Insights saved queries
    4. A subscription filter
    Show answer

    Answer: D. A subscription filter

    Subscription filters send events to Lambda, Kinesis, or Firehose for processing.

  35. Question 35. A developer wants a CloudWatch metric counting log lines that contain "ERROR". What should be created?

    1. A subscription filter to SNS
    2. An X-Ray group with a filter expression
    3. A CloudTrail Insights event
    4. A metric filter on the log group
    Show answer

    Answer: D. A metric filter on the log group

    Metric filters turn matching log events into metric data points that alarms can use.

  36. Question 36. A Step Functions execution fails at one state. Where can the developer see the input, output, and error for each step?

    1. CloudTrail management events for the state machine only
    2. The X-Ray daemon's local log file on the developer's laptop
    3. The execution's event history in the Step Functions console
    4. The IAM role policy attached to the state machine
    Show answer

    Answer: C. The execution's event history in the Step Functions console

    The visual workflow and event history show each state's data and error details.

  37. Question 37. Which Amazon CodeGuru feature finds the most expensive lines of code in a running application?

    1. CodeGuru Reviewer
    2. CodeBuild reports
    3. AWS X-Ray groups
    4. CodeGuru Profiler
    Show answer

    Answer: D. CodeGuru Profiler

    Profiler samples the app in production and shows CPU-heavy code paths. Reviewer analyzes code in pull requests.

AWS, Amazon Web Services, and AWS Certified are trademarks of Amazon.com, Inc. or its affiliates. These questions are original study material, not questions from the real exam.