mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-09 21:29:06 -05:00
perf: reduce SQLite connection count and idle lifetime
On lightly loaded relays, we free up memory faster by letting idle connections be reclaimed in 10 seconds instead of the default 10 minutes. This also sets the minimum to zero connections, instead of always trying to hold one open.
This commit is contained in:
parent
4d746fad85
commit
eba7a32615
|
@ -42,7 +42,7 @@ description = "A newly created nostr-rs-relay.\n\nCustomize this with your own i
|
|||
# Database connection pool settings for subscribers:
|
||||
|
||||
# Minimum number of SQLite reader connections
|
||||
#min_conn = 4
|
||||
#min_conn = 0
|
||||
|
||||
# Maximum number of SQLite reader connections. Recommend setting this
|
||||
# to approx the number of cores.
|
||||
|
|
|
@ -62,7 +62,7 @@ impl SqliteRepo {
|
|||
"writer",
|
||||
settings,
|
||||
OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
false,
|
||||
);
|
||||
|
@ -70,7 +70,7 @@ impl SqliteRepo {
|
|||
"maintenance",
|
||||
settings,
|
||||
OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
true,
|
||||
);
|
||||
|
@ -1199,6 +1199,7 @@ pub fn build_pool(
|
|||
.test_on_check_out(true) // no noticeable performance hit
|
||||
.min_idle(Some(min_size))
|
||||
.max_size(max_size)
|
||||
.idle_timeout(Some(Duration::from_secs(10)))
|
||||
.max_lifetime(Some(Duration::from_secs(30)))
|
||||
.build(manager)
|
||||
.unwrap();
|
||||
|
|
Loading…
Reference in New Issue
Block a user