My Express app running on node 6.11 with Sequelize 4.5.0 will sometimes throw TimeoutError: ResourceRequest timed out
, on operations that should not be particularly expensive. We're talking 5 rows of writes, each executed individually.
The database is an Amazon RDS MySQL instance, that hasn't shown any problems connecting to our second API that is written in Ruby and is using ActiveRecord as an ORM.
I'm not sure how to begin diagnosing the problem, any ideas on what I should do next?
I faced the same problem with sequelize using querys that consume much time. Based on the github issue (https://github.com/sequelize/sequelize/issues/8133#issuecomment-359993057) the fix for me was increase the aquire time. When i instanciate a new sequelize I do the following:
const sequelize = new Sequelize(
config.get("dbConfig.dbName"),
config.get("dbConfig.user"),
config.get("dbConfig.password"),
{
dialect: "mysql",
operatorsAliases: false,
host: config.get("dbConfig.host"),
pool: {
max: 100,
min: 0,
idle: 200000,
// @note https://github.com/sequelize/sequelize/issues/8133#issuecomment-359993057
acquire: 1000000,
}
}
);
This solution works for me:
pool: {
max: 100,
min: 0,
// @note https://github.com/sequelize/sequelize/issues/8133#issuecomment-359993057
acquire: 100*1000,
}
For those of you still using v4 of Sequelize, this problem may have been fixed by v4.44.1.
See PR: https://github.com/sequelize/sequelize/pull/11140
See Issue: https://github.com/sequelize/sequelize/issues/11139
I think I am the best person qualified to answer this question.
This issue has once made my life hell no matter how much I tweaked the configuration.
So there are two solutions to this problem first one is to set the pool config something like this
pool: {
max: 50,
min: 0,
acquire: 1200000,
idle: 1000000,
}
again this will solve your problem for now but again when your load increases you will start to get the error again.
Coming back to the second solution you can really look into table schema or queries you are running against the table.if you are getting these issue that means your queries are not optimized which are taking a much longer time than normal The best bet will be to use indexing on the columns and you will never face this issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With