This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
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.
Overview
When troubleshooting production outages due to 100% CPU usage we use pgbadger to analyze and inspect the database logs. In the report of temp file usage there were some queries that produced temp files over 4MB in size, the default working memory setting for Postgres. The largest temp file we saw in our logs was just over 16MB.
In this PR it we increase the working memory to 20MB in an attempt to have all queries run in memory without spilling onto disk, which is
expensive.
The RDS parameter group value for
work_mem
is specified in KB, so we use a value of 20000.Our database free memory graph always remains stable at at over 2.3GB and we have fewer than ten simultaneous connections to the database at any given time so we do not expect this increase in working memory to cause a free memory issue.
Connects #1727
Demo
Before
Terraform Plan
I looked up the latest deploy CI job to get the GIT_COMMIT value
From inside the terraform container
Note the only valur changes in the
aws_db_parameter_group
are the version number andwork_mem
Terraform apply
From inside the terraform container
After
Testing Instructions
Checklist
fixup!
commits have been squashed