RDS connections in Lambda
In server setup, the connections to RDS DB (Aurora) instances has pool where the connections are bit long lived and cached. This will give us faster connectivity. I would like to understand the guidance on this scenario for serverless/lambda. With lambda there is no sessions and no connections are cached. I think it will create connections every time, it might impact the performance. Are there any workaround or solves/guidance for Lambda ? Is it okay to open the connection every time with the DB instances ? Any leads on this will be super helpful ?
Lambda functions execute in micro VMs. Lambda reuses the micro VM between invocations. For this reason we recommend you create the connection to the database outside the handler (in the init code) and leave it open. As the micro VMs are completely isolated, you can't use a connection pool as you do in servers. For this reason we created RDS Proxy. RDS proxy maintains a connection pool to the database. Your Lambda functions connects to the proxy instead of the directly to the database.
Relevant questions
Using DocumentDB with Lambda: connection pooling
Accepted Answerasked a year agoRDS Proxy Metrics
asked 4 months agoChanges to connection handling with Aurora Postgres?
Accepted Answerasked 3 years agoAWS RDS proxy connection close
Accepted Answerasked 3 months agoUsing RDS Proxy doubles or triples average response times
asked 6 months agoAurora Serverless MySQL - Downtime during scaling event
asked 4 months agoAWS Client VPN timeout
Accepted Answerasked 2 years agoDB Connections Upper Limit
asked 2 years agoRDS connections in Lambda
Accepted Answerasked 25 days agoUse RDS Postgres Replicas as a cluster
Accepted Answerasked 4 months ago