Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda RDS Database Connection Pooling

I am looking for AWS Lambda to handle RDS Database connection pooling mechanism or do we have work around for this????

If we not having option for this i will face max connection error quickly..

like image 791
Shanmuga Sundaram N Avatar asked Jan 10 '18 02:01

Shanmuga Sundaram N


2 Answers

At last your query has been answered by AWS recently.

Amazon RDS Proxy

Hope this helps you out!

like image 190
Nätu Avatar answered Oct 06 '22 19:10

Nätu


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.
like image 23
xcode Avatar answered Oct 06 '22 20:10

xcode