mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-24 08:57:03 -05:00
Limit database max connections by default
Our default of unlimited database connections is not sane, because every database has a limit, and our default should just follow this. Otherwise it will lead to issues every time a small instance gets a high traffic peak. Part of https://codeberg.org/forgejo/forgejo/issues/3381 The value of 100 is the lowest value from: - 100 Postgres https://www.postgresql.org/docs/current/runtime-config-connection.html#GUC-MAX-CONNECTIONS - 151 MySQL https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_connections - 151 MariaDB https://mariadb.com/docs/server/ref/mdb/system-variables/max_connections/
This commit is contained in:
parent
387e63e6f6
commit
f23fd221e4
2 changed files with 3 additions and 3 deletions
|
@ -407,8 +407,8 @@ USER = root
|
||||||
;; Database connection max life time, default is 0 or 3s mysql (See #6804 & #7071 for reasoning)
|
;; Database connection max life time, default is 0 or 3s mysql (See #6804 & #7071 for reasoning)
|
||||||
;CONN_MAX_LIFETIME = 3s
|
;CONN_MAX_LIFETIME = 3s
|
||||||
;;
|
;;
|
||||||
;; Database maximum number of open connections, default is 0 meaning no maximum
|
;; Database maximum number of open connections, default is 100 which is the lowest default from Postgres (MariaDB + MySQL default to 151). Ensure you only increase the value if you configured your database server accordingly.
|
||||||
;MAX_OPEN_CONNS = 0
|
;MAX_OPEN_CONNS = 100
|
||||||
;;
|
;;
|
||||||
;; Whether execute database models migrations automatically
|
;; Whether execute database models migrations automatically
|
||||||
;AUTO_MIGRATION = true
|
;AUTO_MIGRATION = true
|
||||||
|
|
|
@ -83,7 +83,7 @@ func loadDBSetting(rootCfg ConfigProvider) {
|
||||||
Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFETIME").MustDuration(0)
|
Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFETIME").MustDuration(0)
|
||||||
}
|
}
|
||||||
Database.ConnMaxIdleTime = sec.Key("CONN_MAX_IDLETIME").MustDuration(0)
|
Database.ConnMaxIdleTime = sec.Key("CONN_MAX_IDLETIME").MustDuration(0)
|
||||||
Database.MaxOpenConns = sec.Key("MAX_OPEN_CONNS").MustInt(0)
|
Database.MaxOpenConns = sec.Key("MAX_OPEN_CONNS").MustInt(100)
|
||||||
|
|
||||||
Database.IterateBufferSize = sec.Key("ITERATE_BUFFER_SIZE").MustInt(50)
|
Database.IterateBufferSize = sec.Key("ITERATE_BUFFER_SIZE").MustInt(50)
|
||||||
Database.LogSQL = sec.Key("LOG_SQL").MustBool(false)
|
Database.LogSQL = sec.Key("LOG_SQL").MustBool(false)
|
||||||
|
|
Loading…
Reference in a new issue