patternsqlMinor
Limit connection numbers with pgbouncer
Viewed 0 times
pgbouncerwithlimitnumbersconnection
Problem
So I have this pgbouncer config:
And the goal is to limit the number of connections from a specific app - when the db name is database_with_conn_limit, only 55 connections are allowed.
Basically, the apps are identical, but I want one to be limited in connections and the other one grab as many as it wants.
[databases]
my_db = host=10.10.10.10
my_db_with_conn_limit = host=10.10.10.10 dbname=my_db pool_size=55
max_client_conn = 300
default_pool_size = 65
reserve_pool_size = 5
reserve_pool_timeout = 1And the goal is to limit the number of connections from a specific app - when the db name is database_with_conn_limit, only 55 connections are allowed.
Basically, the apps are identical, but I want one to be limited in connections and the other one grab as many as it wants.
- Is this a correct setup?
- Or should I specify pool_size for my_db, too, giving it all Postgres has minus 55?
Solution
You don't have to "specify
But your config won't limit the number of connections though. You need to limit
Otherwise you limit the number of sessions in pool, but not the number of connections...
You can also just set different limits per database+user pair instead (which I believe is more common practice).
pool_size for my_db, too". But your config won't limit the number of connections though. You need to limit
max_db_connections for that like here:[databases]
my_db = host=10.10.10.10
my_db_with_conn_limit = host=10.10.10.10 dbname=my_db pool_size=55 max_db_connections=55Otherwise you limit the number of sessions in pool, but not the number of connections...
You can also just set different limits per database+user pair instead (which I believe is more common practice).
Code Snippets
[databases]
my_db = host=10.10.10.10
my_db_with_conn_limit = host=10.10.10.10 dbname=my_db pool_size=55 max_db_connections=55Context
StackExchange Database Administrators Q#129190, answer score: 5
Revisions (0)
No revisions yet.