mirror of
https://github.com/penpot/penpot.git
synced 2026-11-16 15:11:17 +00:00
🐛 Fix database pool min-size falling back to max-size (#13052)
* 🐛 Fix database pool min-size falling back to max-size Since 2.16 the pool minimum defaults to the maximum (60), so an idle backend opens and holds 60 connections at startup. Restore the pre-2.16 default of 0 so the pool grows with load and idle connections expire. Closes #12622 Signed-off-by: Usama Sadiq <usama7274@gmail.com> * 📚 Document database connection pool settings Describe PENPOT_DATABASE_MIN_POOL_SIZE and PENPOT_DATABASE_MAX_POOL_SIZE, their defaults, and sizing on a PostgreSQL shared with other apps. Signed-off-by: Usama Sadiq <usama7274@gmail.com> --------- Signed-off-by: Usama Sadiq <usama7274@gmail.com>
This commit is contained in:
parent
a19fbbc826
commit
dc340f74af
@ -70,6 +70,7 @@
|
||||
|
||||
(def defaults
|
||||
{::name :main
|
||||
::min-size 0
|
||||
::max-size 60
|
||||
::connection-timeout 30000
|
||||
::validation-timeout 10000
|
||||
@ -92,8 +93,7 @@
|
||||
:read-only read-only
|
||||
:credentials (and (contains? cfg ::username)
|
||||
(contains? cfg ::password))
|
||||
:min-size (or (::min-size cfg)
|
||||
(::max-size cfg))
|
||||
:min-size (::min-size cfg)
|
||||
:max-size (::max-size cfg))
|
||||
(create-pool cfg))))
|
||||
|
||||
@ -117,9 +117,7 @@
|
||||
[{:keys [::uri] :as cfg}]
|
||||
|
||||
;; (app.common.pprint/pprint cfg)
|
||||
(let [config (HikariConfig.)
|
||||
max-size (::max-size cfg)
|
||||
min-size (or (::min-size cfg) max-size)]
|
||||
(let [config (HikariConfig.)]
|
||||
(doto config
|
||||
(.setJdbcUrl (str "jdbc:" uri))
|
||||
(.setPoolName (d/name (::name cfg)))
|
||||
@ -129,8 +127,8 @@
|
||||
(.setValidationTimeout (::validation-timeout cfg))
|
||||
(.setIdleTimeout (::idle-timeout cfg))
|
||||
(.setMaxLifetime (::max-lifetime cfg))
|
||||
(.setMinimumIdle min-size)
|
||||
(.setMaximumPoolSize max-size)
|
||||
(.setMinimumIdle (::min-size cfg))
|
||||
(.setMaximumPoolSize (::max-size cfg))
|
||||
(.setConnectionInitSql initsql)
|
||||
(.setInitializationFailTimeout -1))
|
||||
|
||||
|
||||
@ -757,6 +757,25 @@ POSTGRES_USER: penpot
|
||||
POSTGRES_PASSWORD: penpot
|
||||
```
|
||||
|
||||
#### Connection pool
|
||||
|
||||
The backend keeps a pool of database connections. Its size can be tuned with:
|
||||
|
||||
```bash
|
||||
# Backend
|
||||
PENPOT_DATABASE_MIN_POOL_SIZE: 0
|
||||
PENPOT_DATABASE_MAX_POOL_SIZE: 60
|
||||
```
|
||||
|
||||
The values above are the defaults. The pool keeps at least `MIN_POOL_SIZE` idle
|
||||
connections open and never opens more than `MAX_POOL_SIZE`, growing only under load
|
||||
and closing idle connections after two minutes. A minimum larger than the maximum is
|
||||
capped at the maximum.
|
||||
|
||||
If the PostgreSQL server is shared with other applications, make sure
|
||||
`PENPOT_DATABASE_MAX_POOL_SIZE` plus the connections used by everything else stays below
|
||||
the server's `max_connections` (100 by default).
|
||||
|
||||
### Storage
|
||||
|
||||
Storage refers to storing the user uploaded different objects in Penpot (assets, file data,...).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user