perf(admin-core): cap slave HikariCP pool - #1886
Open
shreyash-jain wants to merge 1 commit into
Open
Conversation
…0×4 replicas = 40 conns) The connection audit showed admin_core_service slave pool was unconfigured in prod (application-stage.properties is dead code since SPRING_PROFILES_ACTIVE=prod). HikariCP defaults gave max=10 / minimum-idle=10 per replica → 40 Postgres connections just for the read replica, the single biggest line in the budget. Capping to max=3, minimum-idle=0 saves ~28 Postgres slots without affecting throughput (the read replica handles negligible traffic today). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Up to standards ✅🟢 Issues
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
admin_core_serviceslave (read-replica) DataSource pool was unconfigured in production.application-stage.properties(which setsspring.datasource.hikari.maximum-pool-size=5) is dead code becauseSPRING_PROFILES_ACTIVE=prodin prod and there is noapplication-prod.properties, so only the baseapplication.propertiesapplies. Additionally, the master-pool overrides there only bind tospring.datasource.hikari.*— the slave bean readsspring.datasource.read.hikari.*(seeDataSourceConfiguration#slaveDataSource→@ConfigurationProperties("spring.datasource.read.hikari")).maximum-pool-size=10,minimum-idle=10) per replica. With 4 admin-core replicas that's 40 idle Postgres connections dedicated to the (lightly used) read replica — the single largest line item in the connection audit.spring.datasource.read.hikari.*overrides to the baseapplication.properties. Capmaximum-pool-size=3,minimum-idle=0, and tightenidle-timeout/connection-timeout. Across 4 replicas this frees ~28 connection slots in the shared Postgres budget. Read throughput is unaffected today (replica handles negligible traffic).maximum-pool-sizeminimum-idleidle-timeoutmax-lifetimeconnection-timeoutPer-replica savings: ~7 connections. With 4 replicas: ~28 connections freed.
Test plan
mvn clean install -DskipTests -pl admin_core_service -am)maximumPoolSize=3, minimumIdle=0DataSourceContextHolderto SLAVE); verify queries succeed and noHikariPool ... Timeout failureerrorspg_stat_activityforapplication_name=admin_core_serviceconnections from the read-replica host — should drop from ~40 to ~12 (3 × 4 replicas) max