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..

Upvotes: 15

Views: 12550

Answers (3)

AWS PS
AWS PS

Reputation: 4710

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/

Upvotes: 1

Nätu
Nätu

Reputation: 332

At last your query has been answered by AWS recently.

Amazon RDS Proxy

Hope this helps you out!

Upvotes: 7

xcode
xcode

Reputation: 31

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.

Upvotes: 3

Related Questions