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

Consider changing defaults for database connections #5802

Open
sorindumitru opened this issue Jan 21, 2025 · 0 comments
Open

Consider changing defaults for database connections #5802

sorindumitru opened this issue Jan 21, 2025 · 0 comments
Labels
triage/in-progress Issue triage is in progress

Comments

@sorindumitru
Copy link
Contributor

Currently we have the following defaults for connections to the database:

  • max open connections - 100
  • max idle connections - 2 (I think we just take this default from db/sql so it might be good to at least document it as such)

This means that any deployments that has some kind of consistent load is going to end up in the situation where connections to the database are being churned. If we end up needing more connections than max idle connections we will need to create a connection, run the query we need to run, and then close it. That doesn't make for very good performance usually.

Having the number of idle connections be somewhat higher if not equal to max open connections ends with less wasted load. That's also what the official documentation recommends for high parallelism apps:

 By default an sql.DB keeps two idle connections at any given moment. Raising the limit can avoid frequent reconnects in programs with significant parallelism.

To make sure that the connections are not kept open indefinitely we can adjust ConnMaxIdleTime to some small values, like 10-60s, so the connections are closed if they are not needed anymore, for example during a burst of activity.

@MarcosDY MarcosDY added the triage/in-progress Issue triage is in progress label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/in-progress Issue triage is in progress
Projects
None yet
Development

No branches or pull requests

2 participants