RE: [EXTERNAL] Re: Limits user connection in pgbouncer

From: "Godfrin, Philippe E" <Philippe(dot)Godfrin(at)nov(dot)com>
To: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>, "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: RE: [EXTERNAL] Re: Limits user connection in pgbouncer
Date: 2021-12-13 12:57:44
Message-ID: SA0PR15MB39338FB3CDBCEA42C55E7A9882749@SA0PR15MB3933.namprd15.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

-----Original Message-----
From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
Sent: Monday, December 13, 2021 2:43 AM
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: [EXTERNAL] Re: Limits user connection in pgbouncer

On 13/12/21 10:05 π.μ., Daulat wrote:
> Hello Team,
> How can we limit the user to  make a specific number of connections to the database?
Just specify this in the db definition configuration :

db1 = host=localhost dbname=db1 pool_size=2

but it will apply to every user, so that every user's pool will have max 2 connections, not only user1.

Alternatively you could set "ALTER ROLE .. CONNECTION LIMIT connlimit " for user1 individually.

>
> Suppose, I have a user "user1" and I want to limit it to make only 2 connections. I have tried but not done.
>
> Here are my pgbouncer.ini options.
>
> db1 = host=localhost dbname=db1
> logfile = /var/log/pgbouncer/pgbouncer.log pidfile =
> /var/run/pgbouncer/pgbouncer.pid listen_addr = * listen_port = 6432
> auth_type = md5 auth_file = /etc/pgbouncer/userlist.txt admin_users =
> postgres pool_mode = session max_client_conn = 300 max_db_connections
> = 2 max_user_connections = 2
>
> Thanks

Take a peek in the delivers pgbouncer.ini file:

;; User-specific configuration
[users]
#postgres=pool_mode=sessio
my_useracct=pool_mode=session max_user_connections=6
your_useracct = pool_mode=transaction max_user_connections=2

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message MichaelDBA 2021-12-13 13:07:32 Re: [EXTERNAL] Re: Limits user connection in pgbouncer
Previous Message Dischner, Anton 2021-12-13 12:25:31 AW: MacOS Application Security