Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PI-2594 Reduce minimum idle DB connections to 1 #4323

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

marcus-bcl
Copy link
Contributor

HikariCP recommends a fixed-size connection pool, so that threads don't have to wait for new connections to be opened during usage spikes. However, with 10 connections per-pod this quickly adds up and is leading to memory exhaustion on the Oracle database.

Each service is typically only using a single connection at a time, with some services spiking to 10 during bulk processing of messages - which lines up with the AWS SQS default of receiving up to 10 messages at a time.

The important part of this change is in helm-defaults, here: PI-2594-reduce-min-pool-size?expand=1#diff-c27a2d56d1

This change means that a single idle connection will always be available for use. As soon as the idle connection is picked up for use from the pool, a new idle connection will be opened to maintain the minimumIdle setting of 1, up until the maximumPoolSize of 10 is reached. If there is more than 1 idle connection, they will be closed after 10 minutes of inactivity until the minimumIdle setting of 1 is reached.

Overall, this means we will be opening and closing connections more often - but the number of open connections at a given time will be much lower than before.

HikariCP recommends a [fixed-size connection pool](https://github.com/brettwooldridge/HikariCP#:~:text=However%2C%20for%20maximum%20performance%20and%20responsiveness%20to%20spike%20demands%2C%20we%20recommend%20not%20setting%20this%20value%20and%20instead%20allowing%20HikariCP%20to%20act%20as%20a%20fixed%20size%20connection%20pool.%20Default%3A%20same%20as%20maximumPoolSize), so that threads don't have to wait for new connections to be opened during usage spikes. However, with 10 connections per-pod this quickly adds up and is leading to memory exhaustion on the Oracle database.

Each service is typically only using a single connection at a time, with some services spiking to 10 during bulk processing of messages - which lines up with the AWS SQS default of receiving up to 10 messages at a time.

This change means that a single idle connection will always be available for use. As soon as the idle connection is picked up for use from the pool, a new idle connection will be opened to maintain the minimumIdle setting of 1, up until the maximumPoolSize of 10 is reached. If there is more than 1 idle connection, they will be closed after 10 minutes of inactivity until the minimumIdle setting of 1 is reached.

Overall, this means we will be opening and closing connections more often - but the number of open connections at a given time will be much lower than before.
@marcus-bcl marcus-bcl requested a review from a team as a code owner October 16, 2024 17:09
@github-actions github-actions bot added the enhancement New feature or request label Oct 16, 2024
@marcus-bcl marcus-bcl merged commit 8dd4912 into main Oct 16, 2024
63 checks passed
@marcus-bcl marcus-bcl deleted the PI-2594-reduce-min-pool-size branch October 16, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants