Change max connections code again

pull/23/head
maru 6 months ago
parent 15a32c0e23
commit 3489ae91bf
No known key found for this signature in database
GPG Key ID: 37689350E9CD0F0D

@ -21,7 +21,6 @@ import (
"database/sql" "database/sql"
"fmt" "fmt"
"log" "log"
"time"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
) )
@ -36,12 +35,10 @@ func Init(username, password, protocol, address, database string) error {
return fmt.Errorf("failed to open database connection: %s", err) return fmt.Errorf("failed to open database connection: %s", err)
} }
conns := 128 conns := 64
handle.SetMaxOpenConns(conns) handle.SetMaxOpenConns(conns)
handle.SetMaxIdleConns(conns / 4) handle.SetMaxIdleConns(conns)
handle.SetConnMaxIdleTime(time.Second * 10)
tx, err := handle.Begin() tx, err := handle.Begin()
if err != nil { if err != nil {

Loading…
Cancel
Save