From fe3708eaf495613cc6e2340b821795f25811d6ed Mon Sep 17 00:00:00 2001 From: bndw Date: Sat, 14 Feb 2026 09:44:55 -0800 Subject: fix: optimize SQLite connection pooling for single-writer architecture Remove misleading max_connections config option and properly configure SQLite connection pooling in the storage layer. Changes: - Set MaxOpenConns(1) for optimal SQLite performance - Set MaxIdleConns(1) to keep connection alive - Set ConnMaxLifetime(0) to never close connection - Remove max_connections and max_lifetime from DatabaseConfig - Update docs to clarify SQLite's single-writer architecture Rationale: SQLite is an embedded database with a single-writer lock. Multiple connections cause lock contention and reduce performance. WAL mode allows concurrent reads from the same connection, making connection pooling unnecessary and counterproductive. This change makes the configuration clearer and ensures optimal SQLite performance by using a single long-lived connection. --- internal/config/README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'internal/config/README.md') diff --git a/internal/config/README.md b/internal/config/README.md index 87d6fa1..79e1b89 100644 --- a/internal/config/README.md +++ b/internal/config/README.md @@ -75,11 +75,8 @@ database: # Path to SQLite database file path: "relay.db" - # Maximum number of open connections - max_connections: 10 - - # Connection max lifetime - max_lifetime: "1h" + # Note: Connection pooling is automatically configured for SQLite. + # SQLite uses a single connection for optimal performance. # Authentication configuration auth: @@ -264,8 +261,6 @@ Server: Database: Path: "relay.db" - MaxConnections: 10 - MaxLifetime: 1h Auth: Enabled: false -- cgit v1.2.3