Azure PostgreSQL 弹性服务器和 Pgbouncer 最大连接数

huangapple go评论69阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月8日 21:42:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75386663.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定