Best Practices for AWS Lambda Container Reuse

Best Practices for AWS Lambda Container Reuse

However, connecting to other services from AWS Lambda adds time to your function code. Option 1 — Connect to RDS Within the Handler
This code example shows how I might naïvely approach this task — the database connection is within the handler method. Reusing the connection significantly reduces the warm start durations — the average duration is approximately 3 times faster and the minimum is 1 ms rather than 18 ms.
Lambda DurationsConnecting to an RDS instance is a time-consuming task, and not having to connect for every invocation is beneficial to performance.

Source: medium.com