Skip to content

Commit

Permalink
chore: postgres-fine-tune (#2147)
Browse files Browse the repository at this point in the history
Signed-off-by: OMPRAKASH MISHRA <[email protected]>
  • Loading branch information
mishraomp authored Oct 28, 2024
1 parent e37df66 commit cd6d7ca
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/.dbdeployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ on:
jobs:
deploy_db:
runs-on: ubuntu-24.04
name: Deploy Crunchy DB If not Deployed
name: Deploy Or Upgrade Crunchy DB
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export async function bootstrap() {
.build();

const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("docs", app, document);
SwaggerModule.setup("/api/docs", app, document);
return app;
}
4 changes: 4 additions & 0 deletions charts/crunchy/templates/PostgresCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,22 @@ spec:
postgresql:
pg_hba: {{ toYaml .Values.crunchy.patroni.postgresql.pg_hba | nindent 10 }}
parameters:
log_min_duration_statement: {{ .Values.crunchy.patroni.postgresql.parameters.log_min_duration_statement }}
shared_buffers: {{ .Values.crunchy.patroni.postgresql.parameters.shared_buffers }}
wal_buffers: {{ .Values.crunchy.patroni.postgresql.parameters.wal_buffers }}
work_mem: {{ .Values.crunchy.patroni.postgresql.parameters.work_mem }}
min_wal_size: {{ .Values.crunchy.patroni.postgresql.parameters.min_wal_size }}
max_wal_size: {{ .Values.crunchy.patroni.postgresql.parameters.max_wal_size }}
max_slot_wal_keep_size: {{ .Values.crunchy.patroni.postgresql.parameters.max_slot_wal_keep_size }}
effective_io_concurrency: {{ .Values.crunchy.patroni.postgresql.parameters.effective_io_concurrency }}
{{- if and .Values.crunchy.proxy .Values.crunchy.proxy.enabled }}
proxy:
pgBouncer:
config:
global:
client_tls_sslmode: disable
pool_mode: session
max_db_connections: {{ .Values.crunchy.proxy.pgBouncer.maxConnections | quote }}
{{ if .Values.crunchy.proxy.pgBouncer.image }}
image: {{ .Values.crunchy.proxy.pgBouncer.image }}
{{ end }}
Expand Down
10 changes: 7 additions & 3 deletions charts/crunchy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ crunchy: # enable it for TEST and PROD, for PR based pipelines simply use single
dataVolumeClaimSpec:
storage: 200Mi
storageClassName: netapp-block-standard
walStorage: 225Mi
walStorage: 255Mi

requests:
cpu: 50m
Expand Down Expand Up @@ -108,15 +108,18 @@ crunchy: # enable it for TEST and PROD, for PR based pipelines simply use single

patroni:
postgresql:
pg_hba:
pg_hba:
- "host all all 0.0.0.0/0 md5"
- "host all all ::1/128 md5"
parameters:
shared_buffers: 16MB # default is 128MB; a good tuned default for shared_buffers is 25% of the memory allocated to the pod
wal_buffers: "64kB" # this can be set to -1 to automatically set as 1/32 of shared_buffers or 64kB, whichever is larger
min_wal_size: 32MB
max_wal_size: 64MB # default is 1GB
max_slot_wal_keep_size: 96MB # default is -1, allowing unlimited wal growth when replicas fall behind
max_slot_wal_keep_size: 128MB # default is -1, allowing unlimited wal growth when replicas fall behind
work_mem: 2MB # a work_mem value of 2 MB
log_min_duration_statement: 1000ms # log queries taking more than 1 second to respond.
effective_io_concurrency: 20 #If the underlying disk can handle multiple simultaneous requests, then you should increase the effective_io_concurrency value and test what value provides the best application performance. All BCGov clusters have SSD.

proxy:
enabled: true
Expand All @@ -129,6 +132,7 @@ crunchy: # enable it for TEST and PROD, for PR based pipelines simply use single
limits:
cpu: 20m
memory: 64Mi
maxConnections: 10 # make sure less than postgres max connections

# Postgres Cluster resource values:
pgmonitor:
Expand Down

0 comments on commit cd6d7ca

Please sign in to comment.