【问题标题】:node-pg-pool: How can specify the max size in Poolnode-pg-pool:如何在 Pool 中指定最大大小
【发布时间】:2018-01-18 11:58:14
【问题描述】:

我正在使用node-pg-pool 在我的 REST API 中查询我的 Postgres 数据库(AWS 中的主机,db.t2.micro)。

我担心如何为池的最大大小指定最佳数量。

我从https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing得到了一些有用的公式来获取池大小

我需要知道 AWS 实例中使用了多少线程、内核和硬盘驱动器(例如:db.t2.micro)。我搜索了 AWS 文档,但仍然找不到所有这些信息

【问题讨论】:

    标签: postgresql connection-pooling amazon-rds node-pg-pool


    【解决方案1】:

    当我使用以下代码连接到 Elephantsql 上的 postgres 数据库时,我成功设置了池大小,aws 应该类似。顺便说一句,您如何连接到 AWS RDS?因为我遇到了很多麻烦

    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=>{});
    

    【讨论】:

      猜你喜欢
      • 2020-11-19
      • 2013-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-23
      • 2018-02-01
      • 2019-04-13
      • 2018-01-25
      相关资源
      最近更新 更多