mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
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:
6
main.go
6
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 {
|
||||
|
||||
Reference in New Issue
Block a user