node-pg-pool: How can specify the max size in Pool

1.3k views Asked by At

I am using node-pg-pool to query my Postgres db (host in AWS, db.t2.micro) in my REST API.

I have a concern how to specify a optimal number for max size of Pool.

I got some useful formulas to get pool size from https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing

I need to know how many threads, cores and hard-drives using in an AWS instance (example: db.t2.micro). I searched AWS documents, and still cannot find all those infos

1

There are 1 answers

0
PrimeLens On

I'm successfully setting pool size when I connect to my postgres db on elephantsql using the following code, aws should be similar. BTW how are you connecting to AWS RDS? as I am having loads of trouble

var poolConfig = {
  max: 5, //connections (was 20 in brianc's repo)
  min: 2, //connections (was 4 in brianc's repo)
  idleTimeoutMillis: 1000 //close idle clients after 1 second
}
poolConfig.user = 'aaaa';
poolConfig.password = 'bbbb';
poolConfig.database = 'ccccc'; 
poolConfig.host = 'ddddd';
poolConfig.port = 5432;
poolConfig.ssl = true;
var pool = new Pool(poolConfig);
pool.connect().then(client => {
  client.query("SELECT table_name FROM information_schema.tables WHERE     table_schema = 'public';")
.then(data=>{});