Skip to content

Commit

Permalink
Update PgBouncer default values (#1045)
Browse files Browse the repository at this point in the history
These values match our standard production deployment template.
  • Loading branch information
gabrieljackson authored Apr 30, 2024
1 parent 36f0777 commit 2bd4077
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/cloud/cluster_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (flags *pgBouncerConfigChanges) addFlags(command *cobra.Command) {

func (flags *pgBouncerConfigOptions) addFlags(command *cobra.Command) {
command.Flags().Int64Var(&flags.minPoolSize, "pgbouncer-min-pool-size", model.PgBouncerDefaultMinPoolSize, "The PgBouncer config for min pool size.")
command.Flags().Int64Var(&flags.defaultPoolSize, "pgbouncer-default-pool-size", model.PgBouncerDefaultPoolSize, "The PgBouncer config for default pool size per user.")
command.Flags().Int64Var(&flags.defaultPoolSize, "pgbouncer-default-pool-size", model.PgBouncerDefaultDefaultPoolSize, "The PgBouncer config for default pool size per user.")
command.Flags().Int64Var(&flags.reservePoolSize, "pgbouncer-reserve-pool-size", model.PgBouncerDefaultReservePoolSize, "The PgBouncer config for reserve pool size per logical database.")
command.Flags().Int64Var(&flags.maxClientConnections, "pgbouncer-max-client-connections", model.PgBouncerDefaultMaxClientConnections, "The PgBouncer config for max client connections.")
command.Flags().Int64Var(&flags.maxDatabaseConnectionsPerPool, "pgbouncer-max-connections-per-pool", model.PgBouncerDefaultMaxDatabaseConnectionsPerPool, "The PgBouncer config for maximum number of proxy database connections per pool (logical database).")
Expand Down
23 changes: 12 additions & 11 deletions model/pgbouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,27 @@ import (
)

// PgBouncerConfig contains the configuration for the PGBouncer utility.
// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// - MaxDatabaseConnectionsPerPool is the maximum number of connections per
// logical database pool when using proxy databases.
// - MinPoolSize is the minimum pool size.
// - DefaultPoolSize is the default pool size per user.
// - ReservePoolSize is the default pool size per user.
// - DefaultPoolSize controls how many server connections to allow per
// user/database pair.
// - ReservePoolSize controls how many additional connections to allow to a
// pool when the default_pool_size is exhausted
// - MaxClientConnections is the maximum client connections.
// - ServerIdleTimeout is the server idle timeout.
// - ServerLifetime is the server lifetime.
// - ServerResetQueryAlways is boolean 0 or 1 whether server_reset_query should
// be run in all pooling modes.
//
// //////////////////////////////////////////////////////////////////////////////
// - ServerResetQueryAlways is boolean 0 or 1 whether server_reset_query
// should be run in all pooling modes.
////////////////////////////////////////////////////////////////////////////////

const (
PgBouncerDefaultMinPoolSize int64 = 1
PgBouncerDefaultPoolSize int64 = 5
PgBouncerDefaultDefaultPoolSize int64 = 5
PgBouncerDefaultReservePoolSize int64 = 10
PgBouncerDefaultMaxClientConnections int64 = 20000
PgBouncerDefaultMaxDatabaseConnectionsPerPool int64 = 20
PgBouncerDefaultMaxClientConnections int64 = 25000
PgBouncerDefaultMaxDatabaseConnectionsPerPool int64 = 50
PgBouncerDefaultServerIdleTimeout int64 = 30
PgBouncerDefaultServerLifetime int64 = 300
PgBouncerDefaultServerResetQueryAlways int64 = 0
Expand Down Expand Up @@ -75,7 +76,7 @@ func (c *PgBouncerConfig) SetDefaults() {
c.MinPoolSize = PgBouncerDefaultMinPoolSize
}
if c.DefaultPoolSize == 0 {
c.DefaultPoolSize = PgBouncerDefaultPoolSize
c.DefaultPoolSize = PgBouncerDefaultDefaultPoolSize
}
if c.ReservePoolSize == 0 {
c.ReservePoolSize = PgBouncerDefaultReservePoolSize
Expand Down

0 comments on commit 2bd4077

Please sign in to comment.