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

Update DB connection pooler config #3333

Merged
merged 2 commits into from
Aug 2, 2023
Merged

Conversation

misaugstad
Copy link
Member

Resolves #3316

Updates the following database connection pooler configs, with the goals of reducing the number of idle connections we hold on to, and reducing the likelihood that a server fails to ever connect to a database after an auto-deploy.

db.default.idleMaxAge=2 minute  # default is 10 minutes
db.default.acquireRetryDelay=5 second  # default is 1 second
db.default.acquireRetryAttempts=42  # default is 10
db.default.minConnectionsPerPartition=4  # default is 5
Testing instructions
  1. Make sure the server is running and you've loaded a webpage
  2. SSH into db container: make ssh target=db
  3. Connect to a db: psql -U sidewalk -d sidewalk
  4. Run this command to list open connections
    SELECT datname, SUM(numbackends) AS "num_conn"
    FROM pg_stat_database
    GROUP BY datname
    HAVING SUM(numbackends) > 0;
    
  5. If you decrease the idleMaxAge to be just a few seconds and you keep running this query, you can watch how the number of connections increases when you load a page, and then goes back down to minConnectionsPerPartition after idleMaxAge.

The retry configs will be a lot easier to test on the test servers!

Things to check before submitting the PR
  • I've written a descriptive PR title.
  • I've added/updated comments for large or confusing blocks of code.

@misaugstad misaugstad self-assigned this Aug 2, 2023
@misaugstad misaugstad merged commit bc18212 into develop Aug 2, 2023
@misaugstad misaugstad deleted the 3316-update-db-config branch August 2, 2023 00:09
@misaugstad misaugstad mentioned this pull request Aug 15, 2023
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 this pull request may close these issues.

Too many database connections are being opened
1 participant