3

In our nodejs app, we started to have SequelizeConnectionAcquireTimeoutError errors. Currently we are using default sequelize connection settings:

{
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
}

How to choose the best value of max pool?

I search lots of similar questions ant websites but I could not find a specific answer to this question. I use sequelize in connection with postgres, The only, most sensible information I found on the Pg wiki: https://wiki.postgresql.org/wiki/Number_Of_Database_Connections

Where is the paragraph "How to Find the Optimal Database Connection Pool Size", and answer (in short):

A formula which has held up pretty well across a lot of benchmarks for years is that for optimal throughput the number of active connections should be somewhere near ((core_count * 2) + effective_spindle_count).

I have found very similar topic on stack overflow which can help provide context of my problem - but without answer. Nodejs, Optimal parameters for sequelize connection pool?

1
  • Did you ever get a grasp on this? Been down the exact same rabbit hole(s) myself, ha. :) Commented Feb 8, 2022 at 17:24

1 Answer 1

3

The formula from the PostgreSQL Wiki assumes that the sessions in the connection pool are never idle, so the limit may be too low. I have suggested an improved formula in my blog.

The problem is that with PostgreSQL versions before v14, it is difficult to estimate how much of your transaction time is spent waiting for the client. You will have to experiment.

The size of the connection pool should be small enough that the database is not overloaded even if all connecrions are in use. There should never be more active connections than you have cores in the database machine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.