From f1fa311d3b7f9d45f340bdbe61ab9f4ab6c66f56 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Tue, 1 May 2018 15:45:11 +0100 Subject: [PATCH] Specify connection limits for mysql kv store backend --- kvs/mysql/main.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kvs/mysql/main.go b/kvs/mysql/main.go index 3f7b56c0..3a25ddc6 100644 --- a/kvs/mysql/main.go +++ b/kvs/mysql/main.go @@ -15,6 +15,8 @@ package mysql import ( + "time" + "strings" "crypto/tls" @@ -68,6 +70,20 @@ func init() { return } + // Set the maximum connection lifetime + + pntr.SetConnMaxLifetime(1 * time.Hour) + + // Set the max number of idle connections + + pntr.SetMaxIdleConns(350) + + // Set the max number of open connections + + pntr.SetMaxOpenConns(350) + + // Return the database pointer + return &DB{pntr: pntr}, err })