英文:
Azure postgres flexible server and pgbouncer max connections
问题
我有一个运行着"General Purpose, D2s_v3, 2 vCores, 8 GiB RAM, 32 GiB存储实例"的Azure PostgreSQL灵活服务器,并且正在使用pg_bouncer进行连接池管理。
在任何时候,都有100个活动连接,当我尝试连接(而不是使用pgbouncer)时,我会收到错误消息"Remaining connection slots are reserved"。我还可以看到偶尔会出现连接错误,看起来是来自pgbouncer,因为在PostgreSQL服务器上没有失败的连接。
服务器配置如下:
max_connections
= 100
pgbouncer.default_pool_size
= 50
pgbouncer.max_client_conn
= 5000
pgbouncer.min_pool_size
= 0
pgbouncer.pool_mode
= TRANSACTION
是否应该增加最大连接数,或者是否有其他配置需要进行调整,以便pgbouncer不分配所有连接?
英文:
I have an Azure postgresql flexible server running a General Purpose, D2s_v3, 2 vCores, 8 GiB RAM, 32 GiB storage instance
and using pg_bouncer for connection pooling.
At all time there are 100 active connections and when I try to connection (not using the pgbouncer) I get the error Remaining connection slots are reserved
. I can also see that there are sporadic errors on connecting that looks to be from pgbouncer as there are not failed connections on the postgresql server.
The server is configured with:
max_connections
= 100 <br>
pgbouncer.default_pool_size
= 50 <br>
pgbouncer.max_client_conn
= 5000 <br>
pgbouncer.min_pool_size
= 0 <br>
pgbouncer.pool_mode
= TRANSACTION <br>
Should the max connections be increased or is there some other configuration that should be adjusted such that pgbouncer don't allocate all connections?
答案1
得分: 0
So in general the only solution was to limit the pgbouncer.default_pool_size
to a number that was low enough to not take up all connections. For example if:
max_connections
= 400
default_pool_size
= 50
With a total of 7 databases and one user connecting to them the max number of connections created by pgbouncer would be 7 * 1 * 50
= 350 which is less than the max_connections.
Unfortunately the few pgbouncer parameters exposed in Azure don't allow for a better configuration other than setting the same configuration for all databases on the server.
英文:
So in general the only solution was to limit the pgbouncer.default_pool_size
to a number that was low enough to not take up all connections. For example if:
max_connections
= 400
default_pool_size
= 50
With a total of 7 databases and one user connecting to them the max number of connections created by pgbouncer would be 7 * 1 * 50
= 350 which is less than the max_connections.
Unfortunately the few pgbouncer parameters exposed in Azure don't allow for a better configuration other than setting the same configuration for all databases on the server.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论