7

If I set up a pgbouncer.ini config file with several database entries, does pgBouncer create a separate pool for each one? I would think so, but have not been able to confirm this.

For example, with something like this:

[databases]
db1 = ...
db2 = ...

[pgbouncer]

.
.
.
max_client_conn = 480

default_pool_size = 250

Would I have a default pool of 250 for each DB and a max of 480, or a total of 250 default and max of 480 connections that are shared between both?

Thanks very much!

2 Answers 2

7

Yes, pgbouncer creates a separate pool for each database. You really don't want a pool size as big as 250 in a scenario like this - because that is 250 connections from pgbouncer to the postgres server for each database.

The max of 480 is the total number of connections from clients into pgbouncer, regardless of which database they go into.

2
  • Would you happen to know when the pool of 250 user connections is created? It can't be on pgbouncer startup as the userid/pwd may not be known yet... Would the 250 connections be created when the first connection from a client is made? May 8, 2018 at 3:01
  • > pgbouncer creates a separate pool for each database I think it is not quite right. pgbouncer creates separate pools per db per user. N users, M databases can make N*M separate pools if all users connect to all databases.
    – Zorg
    Jan 15, 2019 at 0:09
4

Would I have a default pool of 250 for each DB and a max of 480, or a total of 250 default and max of 480 connections that are shared between both?

You will have one pool per DB per user (or role) of you omit specifying user in db1 or db2 lines inside [databases] section. Though you can enforce connecting with some predefined user if you want.

You kind of misunderstood what max_client_conn is . It is the "lightweight" connections limit. The max connections made TO pgbouncer not to database server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.