Adjust per pool by number of pools

default_pool_size, min_pool_size, reserve_pool_size are per pool values,
that's it per (database, user) pair. Which means it's wrong to calculate
them based on the global maxDBConn, otherwise for the cases when there
are too many users it would result in the configuration conflicting
between maxDBConn and min_pool_size. Adjust those values by the number
of known pools.

This not necessarily a perfect solution, because load could be
distributed between databases & users unevenly in which case some of
those parameters will cause rarely used pools being of the same size as
the active ones.
This commit is contained in:
Dmitrii Dolgov 2021-06-09 10:53:40 +02:00
parent 9668ac21a3
commit bfe9224f44
1 changed files with 5 additions and 1 deletions

View File

@ -162,7 +162,11 @@ func (c *Cluster) getConnectionPoolerEnvVars() []v1.EnvVar {
maxDBConn := *effectiveMaxDBConn / *numberOfInstances
defaultSize := maxDBConn / 2
// Following pooler parameters are per pool, which means they have to be
// calculated from the global max db connections adjusted by the number of
// pairs (database, user).
numberOfPools := int32(len(spec.Users) * len(spec.Databases))
defaultSize := (maxDBConn / numberOfPools) / 2
minSize := defaultSize / 2
reserveSize := minSize