Add configuration for Hikari connection pool for database evolutions #480
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.
Out Typerighter PROD deployments have been failing. Upon investigation, the last instance in the auto-scaling group doesn't pass health checks, failing with the following exception:
The PROD RDS database is currently a
db.t4g.micro
which hasmax_connections
of 81, with at least 5 of those connections reserved for internal Postgres processes.The max pool size for database operations is set to 7, so you would think even when doubling the auto-scaling group to 6 instances during deployment, we would be under the threshold. However the app, also uses
applicationEvolutions
to run database evolutions when the app starts. This uses a separate Hikari connection pool which defaults to 10. The initial connections per instance then becomes up to 17 which is TOO MANY :)What does this change?
This sets the Hikari connection pool to something small and sensible, given the size of the database.
How to test
When deployed to CODE we should see the number of connections in the RDS dashboard not spike as highly during deployment. The total number of connections should also decrease. The Rule Manager app should still come up and work as expected (https://manager.typerighter.code.dev-gutools.co.uk/) - we haven't touched the connection pool size for regular database operations, so performance of the app should be unaffected.
How can we measure success?
PROD deploys no longer fail