A Lambda function that inserts new customers into an Amazon RDS database runs multiple times per hour and is slower than expected. The function and RDS are in the same VPC. Which change will improve performance?
Choose an answer
Tap an option to check your answer.
Correct answer: Move the database connection creation and close statements out of the handler so the connection is created in global scope..
Why this is the answer
Moving database connection creation and closing outside the Lambda handler into the global scope allows the connection to be reused across subsequent invocations of the same execution environment. This significantly reduces the overhead of establishing a new connection for each invocation, which is a common performance bottleneck for frequently invoked Lambda functions interacting with databases. Increasing reserved concurrency only ensures the function has enough capacity to run simultaneously, it doesn't improve the performance of individual invocations. Scaling the RDS instance might help if the database itself is the bottleneck, but it doesn't address inefficient connection handling from the Lambda side. Replacing RDS with DynamoDB is a significant architectural change, not a direct performance improvement for an existing RDS-based solution, and DynamoDB's suitability depends on the data model and access patterns.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed