I am developing a service in NodeJS using Express and Sequelize as ORM. I am also using the Serverless Offline plugin to emulate AWS Lambdas and I also deploy my backend in AWS Lambdas. My question is if I can make some configuration either in code or in the database to allow concurrent requests to my backend. The service I am developing will be very busy with users and when making a few requests at the same time, my application fails because there are many connections to the database. What can I do to solve that?
I have tried to configure my sequelize connection pool as follows
const sequelize = new Sequelize(
process.env.DATABASE,
process.env.NAME_SECRET,
process.env.PASS_SECRET,
{
host: process.env.HOST,
port: process.env.PORT_DB,
dialect: process.env.DIALECT_DB,
dialectOptions: {
multipleStatements: true,
},
pool: {
max: 5,
min: 0,
idle: 1000,
acquire: 15000,
evict: 2000,
},
}
);
Since they are AWS Lambdas, I have a connection pool for each lambda with a maximum of 5 connections per pool. Lastly, I tried to create a general pool for all the lambdas but I still have the problem that there are many connections. I’m worried that I won’t be able to solve this, I’m just testing it with an endpoint that doesn’t do much, I have other endpoints that make a lot of queries to the database and it would be worse to solve the problem there.