nerdexam
AmazonAmazon

DVA-C02 · Question #521

DVA-C02 Question #521: Real Exam Question with Answer & Explanation

The correct answer is C: Move the database connection and close statement out of the handler. Place the connection in. Lambda functions that reconnect to a database on every invocation incur significant overhead. Moving the connection outside the handler allows it to persist across warm invocations.

Submitted by packet_pusher· Mar 5, 2026Troubleshooting and Optimization

Question

A developer has implemented an AWS Lambda function that inserts new customers into an Amazon RDS database. The function is expected to run hundreds of times each hour. The function and RDS database are in the same VPC. The function is configured to use 512 MB of RAM and is based on the following pseudo code: After successfully testing the function multiple times, the developer notices that the execution time is longer than expected. What should the developer do to improve performance?

Options

  • AIncrease the reserved concurrency of the Lambda function.
  • BIncrease the size of the RDS database to facilitate an increased number of database connections
  • CMove the database connection and close statement out of the handler. Place the connection in
  • DReplace Amazon RDS with Amazon DynamoDB to implement control over the number of writes

Explanation

Lambda functions that reconnect to a database on every invocation incur significant overhead. Moving the connection outside the handler allows it to persist across warm invocations.

Common mistakes.

  • A. Reserved concurrency controls the maximum number of concurrent instances but does not reduce per-invocation execution time caused by repeated connection establishment.
  • B. Increasing the RDS instance size increases throughput and connection limits but does not reduce the latency caused by opening and closing a new database connection on every invocation.
  • D. Replacing RDS with DynamoDB changes the database technology entirely and is not necessary; the root cause is connection reuse, not the database service itself.

Concept tested. Lambda execution context reuse for database connections

Reference. https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html

Community Discussion

No community discussion yet for this question.

Full DVA-C02 PracticeBrowse All DVA-C02 Questions