AWS Lambda RDS Database Connection Pooling

RDS Proxy has been released but its on Preview mode, it should handle your case

https://aws.amazon.com/about-aws/whats-new/2019/12/amazon-rds-proxy-available-in-preview/


At last your query has been answered by AWS recently.

Amazon RDS Proxy

Hope this helps you out!


There are two aspects to the problem, I had similar issue and this is how I mitigated.

  1. Reusing the database connection pooling, Following is an example where declaring the connection object outside of the handler will help for boost the hot starts

https://github.com/jeffnoehren/Spotinst-Function-Examples/blob/master/node-mysql-connection/handler.js

Here is a good read - http://blog.spotinst.com/2017/11/19/best-practices-serverless-connection-pooling-database/

  1. second aspect of your problem, Reaching the maximum connections, no matter which connection pooling you are using if you don't throttle your lambda invocations there's a upper limit for the invocations. but you haven't mentioned how many requests you are handling. If your lambda invocations are asynchronous I would implement the request being enqueued in the SQS and consume those request asynchronously.