mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-25 21:26:40 +00:00
[chore/performance] use only 1 sqlite db connection regardless of multiplier (#1408)
This commit is contained in:
parent
b80be48fed
commit
4ee4cd2da1
|
@ -128,6 +128,10 @@ db-tls-ca-cert: ""
|
||||||
#
|
#
|
||||||
# If you set the multiplier to less than 1, only one open connection will be used regardless of cpu count.
|
# If you set the multiplier to less than 1, only one open connection will be used regardless of cpu count.
|
||||||
#
|
#
|
||||||
|
# PLEASE NOTE!!: This setting currently only applies for Postgres. SQLite will always use 1 connection regardless
|
||||||
|
# of what is set here. This behavior will change in future when we implement better SQLITE_BUSY handling.
|
||||||
|
# See https://github.com/superseriousbusiness/gotosocial/issues/1407 for more details.
|
||||||
|
#
|
||||||
# Examples: [16, 8, 10, 2]
|
# Examples: [16, 8, 10, 2]
|
||||||
# Default: 8
|
# Default: 8
|
||||||
db-max-open-conns-multiplier: 8
|
db-max-open-conns-multiplier: 8
|
||||||
|
|
|
@ -184,6 +184,10 @@ db-tls-ca-cert: ""
|
||||||
#
|
#
|
||||||
# If you set the multiplier to less than 1, only one open connection will be used regardless of cpu count.
|
# If you set the multiplier to less than 1, only one open connection will be used regardless of cpu count.
|
||||||
#
|
#
|
||||||
|
# PLEASE NOTE!!: This setting currently only applies for Postgres. SQLite will always use 1 connection regardless
|
||||||
|
# of what is set here. This behavior will change in future when we implement better SQLITE_BUSY handling.
|
||||||
|
# See https://github.com/superseriousbusiness/gotosocial/issues/1407 for more details.
|
||||||
|
#
|
||||||
# Examples: [16, 8, 10, 2]
|
# Examples: [16, 8, 10, 2]
|
||||||
# Default: 8
|
# Default: 8
|
||||||
db-max-open-conns-multiplier: 8
|
db-max-open-conns-multiplier: 8
|
||||||
|
|
|
@ -304,9 +304,9 @@ func sqliteConn(ctx context.Context) (*DBConn, error) {
|
||||||
// Tune db connections for sqlite, see:
|
// Tune db connections for sqlite, see:
|
||||||
// - https://bun.uptrace.dev/guide/running-bun-in-production.html#database-sql
|
// - https://bun.uptrace.dev/guide/running-bun-in-production.html#database-sql
|
||||||
// - https://www.alexedwards.net/blog/configuring-sqldb
|
// - https://www.alexedwards.net/blog/configuring-sqldb
|
||||||
sqldb.SetMaxOpenConns(maxOpenConns()) // x number of conns per cpu
|
sqldb.SetMaxOpenConns(1) // only 1 connection regardless of multiplier, see https://github.com/superseriousbusiness/gotosocial/issues/1407
|
||||||
sqldb.SetMaxIdleConns(1) // only keep max 1 idle connection around
|
sqldb.SetMaxIdleConns(1) // only keep max 1 idle connection around
|
||||||
sqldb.SetConnMaxLifetime(0) // don't kill connections due to age
|
sqldb.SetConnMaxLifetime(0) // don't kill connections due to age
|
||||||
|
|
||||||
// Wrap Bun database conn in our own wrapper
|
// Wrap Bun database conn in our own wrapper
|
||||||
conn := WrapDBConn(bun.NewDB(sqldb, sqlitedialect.New()))
|
conn := WrapDBConn(bun.NewDB(sqldb, sqlitedialect.New()))
|
||||||
|
|
Loading…
Reference in a new issue