Database connection pools #
Each DAO node service opens a HikariCP connection pool per database host it connects to. You tune each pool through the databaseConfig block of the DAO’s config, so pools for different DAOs, such as PlayerDataDaoConfig and AccountDaoConfig, are sized independently.
Configure a pool #
Set pool settings alongside the DAO’s connection settings:
game:
serviceConfigs:
PlayerDataDaoConfig:
databaseConfig:
hikariConfigMaximumPoolSize: 50
hikariPrepStmtCacheSize: 1000
| Setting | Default | Description |
|---|---|---|
hikariConfigMaximumPoolSize | 10 | Maximum number of connections in the pool. Also caps how many database operations the DAO runs in parallel. |
hikariMinimumIdleConnections | 0 | Minimum number of idle connections the pool keeps open. |
hikariConfigIdleTimeoutMillis | 300000 | How long a connection can sit idle before it’s closed. |
hikariConnectionTimeoutMillis | 20000 | How long a caller waits for a connection from the pool before failing. |
hikariPrepStmtCacheSize | 500 | Number of prepared statements the driver caches per connection. 0 disables prepared statement caching. |
hikariPrepStmtCacheSqlLimit | 2048 | Maximum length, in characters, of a SQL statement the driver caches. Longer statements are prepared on every use. |
Pool settings are read when the DAO starts. Changing them requires a restart.
A partitioned DAO opens one pool per host, and each pool uses the same settings. The total connections a node holds open to a database server is the sum across all DAOs that it uses, so check the server’s connection limit before raising hikariConfigMaximumPoolSize.
Monitor pools #
Pool metrics are reported as hikaricp_connections_* series. The details dashboard charts connection acquire time and usage time per
pool in the Hikari stats section.
The pool label identifies the pool:
| DAO configuration | pool label |
|---|---|
Uses an identifierSchema | <identifier>-<schema> |
| Partitioned across multiple hosts without identifiers | <schema>-<index> |
| Single host without an identifier | <schema> |
Rising acquire time means callers are waiting for a free connection. Raise hikariConfigMaximumPoolSize, or check for slow queries holding connections longer than expected.