Managing Multiple Concurrent Requests with Aurora and Sequelize

0
6
Asked By CuriousCoder123 On

I'm working on a few Node.js serverless projects that use Aurora Postgresql with Sequelize as the ORM. We've been hitting a wall with the number of concurrent database sessions—our average should be around 2, but it often spikes to 5 or 6. Initially, a lot of this was due to inefficient code, but after some refactoring, the main culprit now seems to be the concurrent requests hitting our Lambdas, which we can't directly control.

I found a few potential solutions:
1. Sequelize has some guidance for Lambdas that I think might help with parallel queries in each function, but I'm not sure it addresses the issue of concurrent connections since new containers are created for requests.
2. Implementing RDS Proxy seems like the best route, though we need to weigh the costs and get approval.
3. We could also utilize SQS for endpoints that don't require an immediate response, and possibly throttle client calls to manage load.

I'm leaning towards a combination of these options. Would you suggest anything else?

4 Answers

Answered By QuerySquasher99 On

It sounds like you're mixing up active sessions with total connections. Active sessions reflect the actual work being done at once, while connection counts don’t really determine that. If your workload is outpacing your DB capabilities, you'll either need to boost your DB size or reduce the workload by optimizing your queries or throttling users.

Answered By ProxyProtagonist On

Definitely go with the RDS Proxy. It’ll manage your connections better and help reduce overhead by keeping things speedy. It’s a wise first step, and after implementation, monitor how performance looks.

Answered By UpgradeAdvocate On

Honestly, it sounds like upgrading to a larger instance could be a simple and effective solution. You're considering various strategies to throttle and queue workloads, but it might just be that your current DB can't handle the load efficiently. Give the upgrade a shot; it's an easy test to run!

Answered By DataDynamo88 On

Your maximum db connections going up to 6 isn’t really that extreme, but if you're experiencing issues, it’s worth looking into. With Sequelize, consider setting the max for request pooling to 2, which could help improve the situation. That way, if your maximum active sessions cap at 2, you'd only use about 4 connections on average. It may help alleviate some of the problems you're facing with timeouts and unexpected connection terminations.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.