Skip to content

Commit

Permalink
Reduce memory usage in dev (#1811)
Browse files Browse the repository at this point in the history
Reduce default memory usage by halving the number work workers per core.
Override works per core for production (we have more memory in prod, so we can keep the number of workers high)
  • Loading branch information
Sybrand authored Mar 25, 2022
1 parent 64c4a9f commit 0607247
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
echo Provision database
CPU_REQUEST=75m CPU_LIMIT=2000m MEMORY_REQUEST=2Gi MEMORY_LIMIT=16Gi PVC_SIZE=45Gi PROJ_TARGET=e1e498-prod bash openshift/scripts/oc_provision_db.sh prod apply
echo Deploy API
CPU_REQUEST=100m CPU_LIMIT=500m MEMORY_REQUEST=3Gi MEMORY_LIMIT=4Gi REPLICAS=3 PROJ_TARGET=e1e498-prod VANITY_DOMAIN=psu.nrs.gov.bc.ca SECOND_LEVEL_DOMAIN=apps.silver.devops.gov.bc.ca bash ./openshift/scripts/oc_deploy.sh prod apply
WORKERS_PER_CORE=0.25 CPU_REQUEST=100m CPU_LIMIT=500m MEMORY_REQUEST=3Gi MEMORY_LIMIT=4Gi REPLICAS=3 PROJ_TARGET=e1e498-prod VANITY_DOMAIN=psu.nrs.gov.bc.ca SECOND_LEVEL_DOMAIN=apps.silver.devops.gov.bc.ca bash ./openshift/scripts/oc_deploy.sh prod apply
echo Env Canada Subscriber
PROJ_TARGET=e1e498-prod bash openshift/scripts/oc_provision_ec_gdps_cronjob.sh prod apply
PROJ_TARGET=e1e498-prod bash openshift/scripts/oc_provision_ec_hrdps_cronjob.sh prod apply
Expand Down
1 change: 1 addition & 0 deletions openshift/scripts/oc_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ OC_PROCESS="oc -n ${PROJ_TARGET} process -f ${PATH_DC} \
-p POSTGRES_READ_HOST=${POSTGRES_READ_HOST:-"patroni-${NAME_APP}-${SUFFIX}-replica"} \
-p VANITY_DOMAIN=${VANITY_DOMAIN} \
${SECOND_LEVEL_DOMAIN:+ "-p SECOND_LEVEL_DOMAIN=${SECOND_LEVEL_DOMAIN}"} \
${WORKERS_PER_CORE:+ "-p WORKERS_PER_CORE=${WORKERS_PER_CORE}"} \
${CPU_REQUEST:+ "-p CPU_REQUEST=${CPU_REQUEST}"} \
${CPU_LIMIT:+ "-p CPU_LIMIT=${CPU_LIMIT}"} \
${MEMORY_REQUEST:+ "-p MEMORY_REQUEST=${MEMORY_REQUEST}"} \
Expand Down
5 changes: 4 additions & 1 deletion openshift/templates/deploy.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ parameters:
value: "False"
- name: VANITY_DOMAIN
requests: True
- name: WORKERS_PER_CORE
description: "Number of workers per core. e.g. openshift pods report having 32 cores, so 0.125 would give you 4 workers total."
value: "0.125"
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -103,7 +106,7 @@ objects:
- name: PORT # The port that the API will run on (used by fastapi docker image)
value: "8080"
- name: WORKERS_PER_CORE # The number of worker per code (used by fastapi docker image)
value: "0.25"
value: ${WORKERS_PER_CORE}
- name: "TIMEOUT" # https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker#timeout
valueFrom:
configMapKeyRef:
Expand Down

0 comments on commit 0607247

Please sign in to comment.