AWS Lambda RDS Database Connection Pooling

☆樱花仙子☆ 提交于 2019-12-23 08:57:13

问题


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


回答1:


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.


来源:https://stackoverflow.com/questions/48179587/aws-lambda-rds-database-connection-pooling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!