【发布时间】:2020-11-25 12:09:12
【问题描述】:
我对 pgbouncer 池大小配置和 ORM(如 sequelize.js)、查询构建器(如 knex.js)库池大小配置感到困惑。这样的架构:
应用程序代码 => pgbouncer => postgresql
pgbouncer.ini:
;; ...
;; Default pool size. 20 is good number when transaction pooling
;; is in use, in session pooling it needs to be the number of
;; max clients you want to handle at any moment
;default_pool_size = 20
;; ...
sequelize 连接池配置:
const sequelize = new Sequelize(/* ... */, {
// ...
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
});
knex.js 连接池配置:
var knex = require('knex')({
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'your_database_user',
password : 'your_database_password',
database : 'myapp_test'
},
pool: { min: 0, max: 7 }
});
如果我同时使用 sequelize.js 连接池配置和 pgbouncer 连接池大小配置会发生什么?数据库服务器使用哪种配置?我应该只使用其中之一吗?谢谢。
【问题讨论】:
标签: postgresql orm sequelize.js knex.js pgbouncer