You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否仅使用Pgpool-II实现负载均衡并禁用其连接池功能?——关于connection_cache参数的有效性咨询

Does setting connection_cache = false disable Pgpool-II's connection pooling?

Great question—yes, setting connection_cache = false is exactly the right way to disable Pgpool-II's connection pooling functionality, which aligns perfectly with your goal of using only HikariCP as your connection pool layer.

Here's a breakdown of what this does:

  • By default, connection_cache is true, which means Pgpool maintains a persistent pool of connections to your PostgreSQL master and slave nodes. It reuses these connections for incoming client requests to avoid the overhead of establishing new connections repeatedly.
  • When you set it to false, Pgpool stops maintaining this cache entirely. Instead, it creates a fresh direct connection to the appropriate PostgreSQL backend node for every incoming client connection request, and closes that connection immediately when the client disconnects. This effectively removes Pgpool's connection pooling layer from the equation.

This is the ideal setup for your Java app using HikariCP. Having multiple layers of connection pooling (like Pgpool + HikariCP, or the earlier issue you had with PgBouncer) often leads to problems like connection exhaustion, timeouts, and inefficient use of database resources. With connection_cache = false, your app's HikariCP will handle all connection pooling logic to Pgpool, while Pgpool focuses solely on what you need it for: routing write queries to the master and read queries to the slaves.

A couple of quick reminders to make this work smoothly:

  • Don’t forget to restart Pgpool-II after updating the configuration—changes to connection_cache won’t take effect until you do.
  • While other connection pool-related settings (like max_pool) won’t have any impact when connection_cache is false, it’s still a good idea to keep them configured sensibly in case you ever need to re-enable pooling later.

内容的提问来源于stack exchange,提问作者cgon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 09:37:41