5.3. HikariCP Connection Pool
5.3.1. Overview
Spring Boot uses HikariCP as the default connection pool. It is included in spring-boot-starter-jooq without any additional dependency configuration.
5.3.2. Key Parameters
| Parameter | Default | Recommended | Description |
|---|---|---|---|
maximum-pool-size | 10 | Adjust per environment | Maximum number of connections |
minimum-idle | 10 | Same as maximum-pool-size | Minimum idle connections |
connection-timeout | 30000 | 30000 (30 sec) | Connection acquisition wait time (ms) |
idle-timeout | 600000 | 600000 (10 min) | Idle connection retention time (ms) |
max-lifetime | 1800000 | 1800000 (30 min) | Maximum connection lifetime (ms) |
leak-detection-threshold | 0 | 60000 (1 min) | Connection leak detection threshold (ms) |
5.3.3. Pool Size Guide by Environment
| Environment | maximum-pool-size | Rationale |
|---|---|---|
| local | 5 | Minimize load on development machine |
| dev | 10 | Default value |
| staging | 15 | Production-like environment |
| prod | 20~30 | Adjust based on traffic volume |
Sizing Formula
HikariCP officially recommended formula: pool_size = (core_count * 2) + effective_spindle_count
In most cases, a value between 10 and 20 is appropriate. An excessive number of connections may actually degrade performance.
5.4. Profile-specific DataSource Configuration
5.4.1. Common Settings (application.yml)
yaml
spring:
datasource:
hikari:
connection-timeout: 30000
idle-timeout: 600000
max-lifetime: 1800000
leak-detection-threshold: 600005.4.2. Local Environment (application-local.yml)
yaml
spring:
datasource:
url: jdbc:postgresql://localhost:5432/flowin
username: flowin
password: flowin1234
hikari:
maximum-pool-size: 55.4.3. Development Environment (application-dev.yml)
yaml
spring:
datasource:
url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
hikari:
maximum-pool-size: 105.4.4. Production Environment (application-prod.yml)
yaml
spring:
datasource:
url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
hikari:
maximum-pool-size: 20
minimum-idle: 20Required
Database connection credentials for development, staging, and production environments must be injected via environment variables. They must not be written directly in application.yml.