Configure HikariCP for Spring Boot on Red Hat OpenShift 4
HikariCP's default settings can leave Spring Boot apps on OpenShift 4 with exhausted or hung database connections. The guide covers configuration through properties, YAML and a Java DataSource bean, then walks through five production failure modes. The first is Hikari's single connection-adder thread blocking forever on a socket read after a network drop, caught with a jcmd-based liveness probe that restarts the pod. The others are egress, NetworkPolicy and DNS problems; replica counts multiplying total connections against database limits; misaligned timeouts, fixed by setting keepaliveTime and keeping maxLifetime below load balancer and firewall idle timeouts; and CFS CPU throttling starving Hikari's housekeeping threads. Leak detection thresholds and Prometheus metrics such as hikaricp_connections_pending help with troubleshooting.
Related posts
- Clouds, caches and connection conundrums
incident.io mediumAdeptAfter migrating to Google Cloud, sporadic Postgres and memcached connection timeouts on GKE turned out to be node-wide, not process-local. Bursts of rapidly opened TCP connections, from concurrent cache sets, GCS URL generation and a runaway query fanning out external calls, spiked CPU in the Dataplane V2 anetd agent and caused dropped packets. Partial mitigations helped: static Postgres pools with a longer connection lifespan cut new connections from ~200/s to ~1/s, and raising memcache MaxIdleConns from 2 to 20 also reduced timeouts. The lasting fix is connection reuse plus limits on outbound network concurrency rather than disabling Dataplane V2. Network timeouts should be investigated at the node level, not just per pod.
- Performance testing: Where benchmarks meet reality
Red Hat Developer mediumAdeptKube-burner performance tests on a customized OpenShift cluster showed that cluster-density workloads met expectations, but node-density tests had unusually high PodInitialized latency even though scheduling looked healthy. Image pulls were ruled out first. Running with --gc=false preserved pods and namespace events, which surfaced 127 Cilium 429 putEndpointIdTooManyRequests errors during pod sandbox creation. Lowering kube-burner's --qps and --burst from 20 to 5 eliminated the errors and cut initialization latency from 45s to 21s, still above the 15s SLO, pointing to the custom CNI as the bottleneck. Much of the remaining text promotes Red Hat Consulting and TAM services.
- Incident Report: April 23rd, 2025
Railway mediumAdeptA Google Cloud SQL maintenance window took Railway's networking control plane Postgres read replica offline for about 10 minutes, destabilizing edge, private networking and TCP proxy traffic across all regions, worst in Asia. Control plane instances crashed on database connection errors because of improper error handling, and each restart evicted the in-memory routing cache, which could not be refetched while Postgres was down. Slow cache warming delayed recovery until 09:28 UTC. Planned fixes include regional control planes to limit blast radius, graceful handling of DB errors, a persistent routing cache as a fallback, faster startup, and Cloud SQL maintenance settings that keep primary and replica from being maintained at the same time.
- The Vanishing Thread and Postgresql TCP Connection Parameters
Instacart Tech mediumAdeptInstacart traced Puma threads that hung for about 15 minutes, ignoring application and database timeouts, to TCP retransmission storms between the app and an AWS NLB in front of PgBouncer. Linux's default tcp_retries2 of 15 with exponential backoff yields roughly 15-minute waits before the OS reports 'Connection timed out'. Setting TCP_USER_TIMEOUT and keepalives per connection through libpq cut failure detection to about 13 seconds. The post also serves as a reference for configuring these parameters in connection strings, Rails, PgBouncer, the Postgres server, logical replication subscriptions and FDW servers. It explains how tcp_user_timeout overrides syn retries and keepalive probes, and how to infer which timeout fired from the elapsed time.
- Thundering herd of circuit breakers
Zalando Engineering mediumAdeptA client's circuit breaker stayed open for hours because its half-open probes hit a service that the HPA had scaled down to three pods. The sparse probes succeeded, the breaker closed, and the withheld traffic arrived at once, queued for over 100 ms per request, timed out and re-opened the breaker. Each cycle lasted only about three seconds, too short for CPU-averaged autoscaling to notice. Zalando found the cycle by exporting OpenTelemetry traces as CSV into a bespoke uPlot visualizer that plots hundreds of traces at once. Suggested fixes are autoscaling on queue depth or concurrency, longer or heavier half-open probes, pre-scaling before the breaker closes, load shedding, and propagating cancellations.