Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are advantages of using transaction pooling with 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?

like image 203
dlamotte Avatar asked Aug 30 '12 02:08

dlamotte


People also ask

What is PgBouncer pool?

PgBouncer allows you to easily set up a connection pool that keeps your database performative, while also managing the connections between your applications and PostgreSQL.

Why should I use PgBouncer?

And below there are 3 reasons why it is be used. It reduces PostgreSQL resource consumption (memory, backends, fork). It supports online restart/upgrade without dropping client connections. It allows PostgreSQL restart/upgrade without dropping client connections.

What is transaction pooling?

Pooling Transaction means an acquisition of the Company in a transaction which is intended to be treated as a "pooling of interests" under generally accepted accounting principles.

What is pool size in PgBouncer?

There are quite a few pool settings for PgBouncer . For example, here are five common settings: pool_size — Just like it sounds: the size of the pool. The default is 20. For Heroku server-side plans, the default is half of your plan's connection limit.


1 Answers

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.

like image 183
Craig Ringer Avatar answered Sep 24 '22 14:09

Craig Ringer