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

Ensure each Rails app container has an appropriate database connection pool size #340

Closed
timcowlishaw opened this issue Jul 16, 2024 · 0 comments · Fixed by #342
Closed
Assignees

Comments

@timcowlishaw
Copy link
Contributor

Postgres allows 100 maximum simultaneous connections in our current configuration, which should be more than enough for our own purposes.

However we haven't been using them effectively (giving a connection pool size of 10 to each of mqtt-task, auth, api and sidekiq), leading to errors in sidekiq jobs - as sidekiq 25 worker threads in production.

I've upped this to 25 per container (since there are 4), which in theory should have solved the sidekiq problem (25 threads, 25 connections, should be one each). However we're still seeing occasional errors: I assume that sidekiq also has some sort of manager thread which itself can use a connection.

I've temporarily decreased the number of sidekiq worker threads in production to 20, which seems to have stopped the errors. However, this isn't ideal, most notably because mqtt-task is single threaded and therefore has 24 connections more than it actually needs.

A better solution would be to provide an appropriately sized connection pool to each service, however, the pool size is currently set by an env variable in the shared env file. A better approach would be to set this per-service in the docker compose file.

This ticket is to do this, as well as to research and set appropriate database connection pool sizes for each service.

@timcowlishaw timcowlishaw self-assigned this Jul 16, 2024
@timcowlishaw timcowlishaw linked a pull request Jul 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant