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.
This commit is contained in:
Houmgaor
2026-02-02 18:28:54 +01:00
parent 4f655cc041
commit ae2928ad57

View File

@@ -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 {