问题描述
对于使用pgbouncer进行事务池与会话池的优缺点,我很难找到一个很好的总结。
I'm having trouble finding a good summary of the advantages/disadvantages of using pgbouncer for transaction pooling vs session pooling.
这是否意味着事务繁重的工作量更好地平衡负载?
Does it mean that a transaction heavy workload is somehow better load balanced? Is it to prevent as many connections being required to connect from pgbouncer to the database?
推荐答案
如果您需要事务级别的池连接,是否可以防止从pgbouncer连接到数据库所需的连接数量过多?有保存空闲会话的应用。 PgBouncer不需要保持会话打开和空闲,它只是在开始新事务时抓取一个会话。这些空闲会话仅使您花费pgbouncer连接,而不是真正的空闲Pg会话,因为后端坐在浪费内存的同时
Transaction-level pooling will help if you have apps that hold idle sessions. PgBouncer won't need to keep sessions open and idle, it just grabs one when a new transaction is started. Those idle sessions only cost you a pgbouncer connection, not a real idle Pg session with a backend sitting around wasting memory & synchronisation overhead doing nothing.
您希望会话池而不是事务池的主要原因是,如果您要使用命名的准备好的语句,咨询锁,监听/通知,或其他在会话级别而非交易级别上运行的功能。
The main reason you'd want session pooling instead of transaction pooling is if you want to use named prepared statements, advisory locks, listen/notify, or other features that operate on a session level not a transaction level.
这篇关于在pgbouncer中使用事务池有什么优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!