PgBouncer
A lightweight connection-pooling middleware for PostgreSQL. Running as a standalone process between an application and the database, it reduces connection-establishment overhead by reusing existing database connections, significantly improving database access performance under high-concurrency workloads.
Timeline (last 90 days)
Common implementations of connection pooling include the standalone process PgBouncer (suitable for ultra-high concurrency) and application-layer connection pools (such as n8n's built-in TypeORM connection pool).
Transaction pooling 是生产环境中最常用的模式,在每个事务结束后将后端连接归还到池中,但会导致跨事务的会话级特性不可用
PgBouncer 1.21+ 版本已部分支持 PREPARE/DEALLOCATE 预处理语句
Statement pooling 在每条 SQL 语句执行完毕后回收连接,完全不支持多语句事务,仅适用于 autocommit 模式
In addition to connection pooling, Pgpool-II provides capabilities such as load balancing, automatic failover, parallel queries, and online recovery, but its pure connection pooling performance is inferior to PgBouncer.
PgBouncer 提供三种池化模式:会话级(Session)、事务级(Transaction)和语句级(Statement)
A Hacker News question about running PostgreSQL in production without PgBouncer received 40 upvotes and multiple comments.
事务级池化仅在事务执行期间占用连接,是最常用的高效模式
会话级池化在整个客户端会话期间独占连接,兼容性最好但复用率最低
当应用连接数远低于 max_connections 上限、使用应用层连接池且连接生命周期较长时,可以不使用 PgBouncer
1 more timeline events
All Facts (10)
In addition to connection pooling, Pgpool-II provides capabilities such as load balancing, automatic failover, parallel queries, and online recovery, but its pure connection pooling performance is inferior to PgBouncer.
60%UnverifiedCommon implementations of connection pooling include the standalone process PgBouncer (suitable for ultra-high concurrency) and application-layer connection pools (such as n8n's built-in TypeORM connection pool).
50%UnverifiedTransaction pooling 是生产环境中最常用的模式,在每个事务结束后将后端连接归还到池中,但会导致跨事务的会话级特性不可用
50%UnverifiedPgBouncer 1.21+ 版本已部分支持 PREPARE/DEALLOCATE 预处理语句
50%UnverifiedStatement pooling 在每条 SQL 语句执行完毕后回收连接,完全不支持多语句事务,仅适用于 autocommit 模式
50%UnverifiedPgBouncer 提供三种池化模式:会话级(Session)、事务级(Transaction)和语句级(Statement)
50%Unverified会话级池化在整个客户端会话期间独占连接,兼容性最好但复用率最低
50%Unverified事务级池化仅在事务执行期间占用连接,是最常用的高效模式
50%Unverified当应用连接数远低于 max_connections 上限、使用应用层连接池且连接生命周期较长时,可以不使用 PgBouncer
50%Unverified应用层连接池管理单个应用实例内部的连接复用,而 PgBouncer 解决集中式前置连接池问题,两者解决不同层面的问题
50%