HikariCP là JDBC connection pool — giữ sẵn pool kết nối DB tái sử dụng thay vì mở/đóng connection mỗi request (mở connection tốn hàng chục ms + handshake).
Là default của Spring Boot 2+ vì: nhanh nhất trong benchmark (vs Tomcat CP, DBCP2, C3P0) — overhead borrow/return cực thấp; lightweight (~170KB); reliable.
Tham số chính (prefix spring.datasource.hikari.*):
- maximum-pool-size — max connection (default 10).
- minimum-idle — số connection idle giữ sẵn.
- connection-timeout — ms chờ lấy connection trước khi throw.
- max-lifetime — tuổi thọ tối đa 1 connection.
- leak-detection-threshold — cảnh báo khi connection bị giữ quá lâu → bắt bug code quên trả pool.
Pool size: không phải càng nhiều càng tốt — DB giới hạn concurrent connection. Công thức HikariCP: (core_count × 2) + effective_spindle_count; Postgres khuyến nghị 10-20 connection/app instance.