From ae2928ad572a8872e41c5ed48a667ae84bc74237 Mon Sep 17 00:00:00 2001 From: Houmgaor Date: Mon, 2 Feb 2026 18:28:54 +0100 Subject: [PATCH] feat(db): add connection pool configuration Configure database connection pool to support 50+ concurrent players: - MaxOpenConns: 50 (prevents connection exhaustion) - MaxIdleConns: 10 (keeps warm connections ready) - ConnMaxLifetime: 5 min (recycles stale connections) - ConnMaxIdleTime: 2 min (closes idle connections) Prevents "too many connections" errors under load and improves connection reuse efficiency. --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 0f870cd59..0b6cd8337 100644 --- a/main.go +++ b/main.go @@ -184,6 +184,12 @@ func main() { preventClose(fmt.Sprintf("Database: Failed to open, %s", err.Error())) } + // Configure connection pool for concurrent players + db.SetMaxOpenConns(50) // Support 50+ concurrent players + db.SetMaxIdleConns(10) // Keep idle connections ready + db.SetConnMaxLifetime(5 * time.Minute) // Recycle stale connections + db.SetConnMaxIdleTime(2 * time.Minute) // Close idle connections + // Test the DB connection. err = db.Ping() if err != nil {