question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suitable values for poolSize, poolIdleTimeout and reapIntervalMillis

See original GitHub issue

This 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:closed
  • Created 7 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
abenhamdinecommented, Aug 30, 2017

@rue you’re right, I think poolIdelTimeOut, returnToHead, and reapIntervalMillis have 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/1438

0reactions
charmandercommented, Dec 6, 2019

There’s a connection timeout option now to address https://github.com/brianc/node-postgres/issues/1222#issuecomment-282052787, and idleTimeoutMillis replaces poolIdleTimeout. 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.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connection | The PostgreSQL handler you have dreamed of :)
'all' | 'select' | 'none'; //if there is a undefined value in the query condition, ... Still the best if no undefined value...
Read more >
Node.js PostgreSQL - Stack Overflow
Suitable values for poolSize, poolIdleTimeout and reapIntervalMillis #1222 · pg.defaults.poolSize vs pg-pool #1102 · PG.connect never calls-back ...
Read more >
[Solved]-Node.js PostgreSQL-postgresql - appsloveworld
The proper way for using node.js postgres module is to have a connection ... #931 · Suitable values for poolSize, poolIdleTimeout and reapIntervalMillis...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found