Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions server/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
user=atum_user
password=changeme
passwordSecretId="serviceUserSecretKey"
# maximum number of connections that HikariCP will keep in the pool, including both idle and in-use connections
maxPoolSize=10
# Pool settings
minimumIdle=4 # Min number of idle connections Hikari maintains in the pool. default = maxPoolSize
maxPoolSize=10 # Max number of connections that HikariCP will keep in the pool, including both idle and in-use ones
# Connection lifecycle settings
idleTimeout=180000 # How long a connection can sit idle in the pool before being removed.
keepaliveTime=60000 # How often Hikari sends a keep-alive query to verify the connection is still valid while it's idle in the pool.
maxLifetime=600000 # Refresh connections regularly
# Misc settings
leakDetectionThreshold=60000 # this is disabled by default
prometheusMetricsEnabled=true
}
aws {
region = "af-south-1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package za.co.absa.atum.server.api.database

import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory
import doobie.hikari.HikariTransactor
import io.prometheus.client.CollectorRegistry
import za.co.absa.atum.server.config.PostgresConfig
import zio.Runtime.defaultBlockingExecutor
import zio._
Expand All @@ -40,8 +42,24 @@ object TransactorProvider {
val config = new HikariConfig()
config.setDataSourceClassName(postgresConfig.dataSourceClass)
config.setDataSourceProperties(dataSourceProperties)
config.setMaximumPoolSize(postgresConfig.maxPoolSize)

// Pool settings, especially sizing
config.setPoolName("DoobiePostgresHikariPool")
config.setMinimumIdle(postgresConfig.minimumIdle)
config.setMaximumPoolSize(postgresConfig.maxPoolSize)

// Connection lifecycle settings
config.setIdleTimeout(postgresConfig.idleTimeout)
config.setKeepaliveTime(postgresConfig.keepaliveTime)
config.setMaxLifetime(postgresConfig.maxLifetime)

// Misc DB settings
config.setLeakDetectionThreshold(postgresConfig.leakDetectionThreshold)

// Prometheus metrics integration
if (postgresConfig.prometheusMetricsEnabled)
config.setMetricsTrackerFactory(new PrometheusMetricsTrackerFactory(CollectorRegistry.defaultRegistry))

config
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ case class PostgresConfig(
databaseName: String,
user: String,
password: String,
passwordSecretId: String,
minimumIdle: Int,
maxPoolSize: Int,
passwordSecretId: String
idleTimeout: Int,
keepaliveTime: Int,
maxLifetime: Int,
leakDetectionThreshold: Int,
prometheusMetricsEnabled: Boolean
)

object PostgresConfig {
Expand Down
Loading