Skip to content

Pre-tune PostgreSQL for CircleCI & test with 15.2 [release] #67

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

Merged
merged 1 commit into from
Mar 29, 2023

Conversation

FelicianoTech
Copy link
Contributor

This PR attempts to pre-tune PostgreSQL. Part of the point of this is to help solve problems like #47 since we can't dynamically change my PG settings.

This PR also builds the new PG v15.2 image as a way to test these changes.

Whether this is merged or not, we need to build v15.2 and other new releases though if we merge this, those releases should come after.

Also, if this works, we should determine how far back to make the change. The requester in #47 seems to be using 11.x so not recent.

@FelicianoTech FelicianoTech requested a review from a team as a code owner February 20, 2023 19:10
@BytesGuy
Copy link
Contributor

BytesGuy commented Feb 20, 2023

@FelicianoTech Looks good to me in principle. Do we have any benchmarks on this? Perhaps pgbench to see how much this improves the performance whilst testing stability?

@FelicianoTech
Copy link
Contributor Author

@BytesGuy No benchmarks. How do you use pgbench with this image to do so? I determined the changed defaults based on prior knowledge, some reading, and playing with pgtune.

@BytesGuy
Copy link
Contributor

BytesGuy commented Feb 21, 2023

@FelicianoTech This is what I used to test if ram disks would make any performance difference. Off the top of my head this will create a database and populate it, then simulator a load of clients running multiple queries

      - run: pgbench -i -s 100 -h 127.0.0.1 -p 5432 -d $TEST_DATABASE_URL --quiet
      - run: pgbench -c 100 -T 300 -S -n -p 5432 -d $TEST_DATABASE_URL >> benchmark 2>&1
      - run: tail -n 50 benchmark

It might help with some finer tuning :)

@JalexChen
Copy link

i think the changes themselves are fine, but i'm not sure what the benchmarking would be used for specifically in this case; are we looking for any specific increases in performance with pgbench and pgtune or is this more for addressing how to configure in #47?

@JalexChen
Copy link

JalexChen commented Mar 2, 2023

after investigating this issue further:

  • should we follow through with the revert in Revert "replace docker-entrypoint with latest (#69)" #71? this change is not deterministic, but there aren't many changes being made to that file. the most important one is actually the addition of listen_addresses = '*' for testing purposes.

  • technically, the dockerfile has a backwards compatibility symlink, so it could use either the upstream entrypoint or the one that is copied over within this repo. if we do not revert, i would still need to add the old docker-entrypoint.sh back in so older dockerfile versions can still build, but this would be backwards compatible

  • i think having the addition of the separate postgres.conf makes sense since it allows users to customize their configuration, especially for settings that can only be set at a certain time. this would also allow us to set the listen_addresses = '*' configuration within this file instead of in the entrypoint, which facilitates pulling from upstream

  • specifying a postgres.conf is compatible and is documented as one of the ways to do it, so i think this would work for old and new releases without needing to know exactly how far back to go. this would require a change in the CI config to specify the config file to point to /etc/postgresql/postgresql.conf e.g docker run --rm --env POSTGRES_USER=user --env POSTGRES_PASSWORD=passw0rd -p 5432:5432 -d -c config_file="/etc/postgresql/postgresql.conf" $IMAGE

@BytesGuy
Copy link
Contributor

BytesGuy commented Mar 3, 2023

@JalexChen

  • Yes, let's revert this for now until we have a better solution
  • As above, let's revert for now to keep things simple
  • This is a good idea, we can keep custom configuration separate this way
  • We will definitely want to ensure this is well documented from our side too

@JalexChen
Copy link

Closes #47

@BytesGuy
Copy link
Contributor

@JalexChen This looks good to merge 👍

@JalexChen JalexChen merged commit 9d42e7f into main Mar 29, 2023
@dheerajck
Copy link

Can we add these parameters to postgres config
https://discuss.circleci.com/t/can-postgres-config-postgresql-conf-file-be-changed-using-circle-yml/10621/4

fsync=off
synchronous_commit=off
full_page_writes=off
bgwriter_lru_maxpages=0

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.

4 participants