Skip to content

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

ParameterDefaultRecommendedDescription
maximum-pool-size10Adjust per environmentMaximum number of connections
minimum-idle10Same as maximum-pool-sizeMinimum idle connections
connection-timeout3000030000 (30 sec)Connection acquisition wait time (ms)
idle-timeout600000600000 (10 min)Idle connection retention time (ms)
max-lifetime18000001800000 (30 min)Maximum connection lifetime (ms)
leak-detection-threshold060000 (1 min)Connection leak detection threshold (ms)

5.3.3. Pool Size Guide by Environment

Environmentmaximum-pool-sizeRationale
local5Minimize load on development machine
dev10Default value
staging15Production-like environment
prod20~30Adjust 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: 60000

5.4.2. Local Environment (application-local.yml)

yaml
spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/flowin
    username: flowin
    password: flowin1234
    hikari:
      maximum-pool-size: 5

5.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: 10

5.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: 20

Required

Database connection credentials for development, staging, and production environments must be injected via environment variables. They must not be written directly in application.yml.

TIENIPIA QUALIFIED STANDARD