Skip to content

Commit

Permalink
feat: set DB con TTL to 1m (#2869)
Browse files Browse the repository at this point in the history
This is not perfect, but is way better than opening a new connection
every time when under load

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
stuartwdouglas and github-actions[bot] authored Sep 27, 2024
1 parent 06cd968 commit cee6c95
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go-runtime/ftl/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"fmt"
"time"

"github.com/XSAM/otelsql"
"github.com/alecthomas/types/once"
Expand Down Expand Up @@ -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
}),
}
Expand Down

0 comments on commit cee6c95

Please sign in to comment.