Technology1 min read

Configure HikariCP for Spring Boot on Red Hat OpenShift 4

By · Published by Everything Blog

In short

Unoptimized default pool configurations often lead to service outages in containerized environments facing resource constraints. Engineers can resolve these bottlenecks by tuning connection timeouts and establishing fixed pool sizes using application configuration files or Java DataSource beans. Maven projects integrate these capabilities directly through the core Spring Boot JDBC starter and dedicated database drivers. Leak detection thresholds can also be activated to rapidly identify unclosed connections during production operations.

Key points

  • Setting explicit limits on minimum idle connections and maximum pool sizes ensures resili…: Setting explicit limits on minimum idle connections and maximum pool sizes ensures resilience during high-load periods.
  • Developers can apply pool properties programmatically through Java beans or inside standa…: Developers can apply pool properties programmatically through Java beans or inside standard configuration files.
  • Configuring leak detection threshold settings enables operators to identify unclosed conn…: Configuring leak detection threshold settings enables operators to identify unclosed connections causing performance bottlenecks.

Sources checked by our analysis pipeline: 1

When a Spring Boot application running on Red Hat OpenShift 4 suddenly stops serving traffic due to exhausted or hung database connections, default HikariCP configurations are often the culprit. Here is how to configure, monitor, and troubleshoot Hikari connection pools to survive network drops and container CPU throttling.

If you are already running Spring Boot on Red Hat OpenShift, you might have tackled Java Virtual Machine (JVM) memory tuning and Red Hat Data Grid integration (see Integrate a Spring Boot application with Red Hat Data Grid and How to troubleshoot Spring Boot in OpenShift). This guide focuses on the layer in between: how Hikari manages database connections under container constraints.

Hikari use in Spring Boot

You can configure Hikari in Spring Boot through application.properties

, for example:

# Database Connection Settings

spring.datasource.url=jdbc:postgresql://localhost:5432/db

spring.datasource.username=dbuser

spring.datasource.password=dbpass

spring.datasource.driver-class-name=org.postgresql.Driver

# HikariCP Specific Settings

# Fixed pool size (Recommended for high-load/SDN environments)

spring.datasource.hikari.minimum-idle=20

spring.datasource.hikari.maximum-pool-size=20

# Timeouts and Lifecycle

spring.datasource.hikari.idle-timeout=300000

spring.datasource.hikari.max-lifetime=1800000

spring.datasource.hikari.connection-timeout=30000

spring.datasource.hikari.validation-timeout=5000

# Monitoring & Debugging

spring.datasource.hikari.pool-name=InfinispanAuditHikariPool

spring.datasource.hikari.leak-detection-threshold=5000

You can also configure a DataSource

bean programmatically in Java:

@Configuration

public class DataSourceConfig {

@Bean

@ConfigurationProperties("spring.datasource.hikari")

Technology