From cee6c95d2c913ea05aeb7bfc1817cb9c76ea0617 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Fri, 27 Sep 2024 19:27:38 +1000 Subject: [PATCH] feat: set DB con TTL to 1m (#2869) This is not perfect, but is way better than opening a new connection every time when under load --------- Co-authored-by: github-actions[bot] --- go-runtime/ftl/database.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go-runtime/ftl/database.go b/go-runtime/ftl/database.go index d0d4a18fb6..c0c6717654 100644 --- a/go-runtime/ftl/database.go +++ b/go-runtime/ftl/database.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "fmt" + "time" "github.com/XSAM/otelsql" "github.com/alecthomas/types/once" @@ -47,6 +48,8 @@ func PostgresDatabase(name string) Database { if err != nil { return nil, fmt.Errorf("failed to register database metrics: %w", err) } + db.SetConnMaxIdleTime(time.Minute) + db.SetMaxOpenConns(20) return db, nil }), }