Suitable values for poolSize, poolIdleTimeout and reapIntervalMillis
See original GitHub issueThis is more of a question than an issue.
I’m using node-postgres and have had some issues with the connection pool getting exhausted (I think mainly due to connection leaks). I’m trying to find out the optimal values for pool size and timeouts. Let’s say I expect to have 1000 concurrent users and most users will be making requests that result in db requests. My database server has limited resources with 1 CPU and 2GB or RAM.
What would be the ideal values for these settings? I’m currently using this:
pg.defaults.poolSize = 25;
pg.defaults.reapIntervalMillis = 1000;
pg.defaults.poolIdleTimeout = 1000;
Also I’m a question about the poolIdleTimeout. The comments in the code says:
max milliseconds a client can go unused before it is removed from the pool and destroyed
Does this mean the amount of time before the connection is closed and returned to the pool, or the connection is closed and removed from the pool, thus decreasing pool size?
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (3 by maintainers)

Top Related StackOverflow Question
@rue you’re right, I think
poolIdelTimeOut,returnToHead, andreapIntervalMillishave been removed with the update to 7.x. FI, there’s still some remaining occurrences in default.js, see https://github.com/brianc/node-postgres/pull/1438There’s a connection timeout option now to address https://github.com/brianc/node-postgres/issues/1222#issuecomment-282052787, and
idleTimeoutMillisreplacespoolIdleTimeout. Documentation at https://node-postgres.com/api/pool/. (As for the original issue, ignoring leaks: the ideal pool size and idle timeout depend on too many factors to prioritize in documentation, I think, and the defaults will usually not be the issue except to people who’ll know where to look.)