I've been working on several serverless Node.js projects that make use of Aurora PostgreSQL with Sequelize as the ORM. We're running into issues with the number of concurrent database connections. Our expected average active sessions (AAS) should be around 2, but we're frequently seeing it spike to 5 or 6 throughout the hour. Previously, we had a lot more issues due to inefficient code causing extra queries, but after refactoring, the main problem now seems to stem from the concurrent requests to our Lambdas, which are harder to manage.
I have a few possible solutions in mind: 1) Sequelize has documentation on optimizing it for use with Lambdas, but it seems that it won't truly help with concurrent requests since the containers aren't reused, meaning we'd still end up with many concurrent database connections. 2) Implementing RDS Proxy appears to be a good option, though I need to weigh the costs and get buy-in. 3) Utilizing SQS for workloads that don't require immediate responses. 4) Throttling API calls to reduce the load from clients.
I'm considering implementing all these options, maybe putting off SQS for later since it requires more changes. Any additional suggestions?
1 Answer
From what I've gathered in this discussion, it seems upgrading your database instance size might the best move. You're discussing throttling and queuing, but the workload seems too much for your current setup. Testing a larger instance could be an easy and effective fix.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String