我正在使用node-pg-pool在我的REST API中查询我的postgres db(AWS,db.t2.micro中的主机)。
我有一个关注的方式如何指定池的最大大小的最佳数字。
我有一些有用的公式可以从https://github.com/brettwooldridge/hikaricp/wiki/about-pool-sizing
获得池大小我需要知道在AWS实例中使用了多少个线程,内核和硬盘驱动器(示例:db.t2.micro)。我搜索了AWS文档,但仍然找不到所有这些Infos
使用以下代码连接到ElephantsQL上的Postgres DB时,我成功地设置了池大小,AWS应该相似。顺便说一句,您如何连接到AWS RD?当我有很多麻烦
时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=>{});