From f26fdbac77314ac1d17e62fd6ad348423dbc37f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bournhonesque?= Date: Thu, 4 Jul 2024 11:58:06 +0200 Subject: [PATCH] chore: increase SHARED_BUFFERS and WORK_MEM (#1354) --- .env | 9 ++++++++- .github/workflows/container-deploy.yml | 6 +++++- docker-compose.yml | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 1d68e8f125..9e8d938bfc 100644 --- a/.env +++ b/.env @@ -92,4 +92,11 @@ ENABLE_MONGODB_ACCESS=0 GUNICORN_PRELOAD_APP=0 # The log level for the robotoff service -LOG_LEVEL=DEBUG \ No newline at end of file +LOG_LEVEL=DEBUG + +# PostgreSQL configuration + +# Use 16G in production +ROBOTOFF_POSTGRES_SHARED_BUFFERS=1GB +# Use 1G in production +ROBOTOFF_POSTGRES_WORK_MEM=64MB \ No newline at end of file diff --git a/.github/workflows/container-deploy.yml b/.github/workflows/container-deploy.yml index 9fd4bcdad6..92c2b1a07f 100644 --- a/.github/workflows/container-deploy.yml +++ b/.github/workflows/container-deploy.yml @@ -134,10 +134,14 @@ jobs: echo "INFLUXDB_BUCKET=off_metrics" >> .env echo "INFLUXDB_AUTH_TOKEN=${{ secrets.INFLUXDB_AUTH_TOKEN }}" >> .env echo "SLACK_TOKEN=${{ secrets.SLACK_TOKEN }}" >> .env - echo "GUNICORN_NUM_WORKERS=8" + echo "GUNICORN_NUM_WORKERS=8" >> .env echo "EVENTS_API_URL=https://event.openfoodfacts.${{ env.ROBOTOFF_TLD }}" >> .env echo "IMAGE_MODERATION_SERVICE_URL=${{ env.IMAGE_MODERATION_SERVICE_URL }}" >> .env + # PostgreSQL config + echo "ROBOTOFF_POSTGRES_SHARED_BUFFERS=16GB" >> .env + echo "ROBOTOFF_POSTGRES_WORK_MEM=1GB" >> .env + - name: Create Docker volumes uses: appleboy/ssh-action@master diff --git a/docker-compose.yml b/docker-compose.yml index c9eb4d61c2..59bfae3a45 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -109,8 +109,8 @@ services: - postgres-data:/var/lib/postgresql/data - backup:/opt/robotoff-backups - ./scripts/backup_postgres.sh:/opt/backup_postgres.sh - command: postgres -c shared_buffers=1024MB -c work_mem=64MB - mem_limit: 4g + command: postgres -c shared_buffers=${ROBOTOFF_POSTGRES_SHARED_BUFFERS} -c work_mem=${ROBOTOFF_POSTGRES_WORK_MEM} + mem_limit: 20g shm_size: 1g ports: - "${POSTGRES_EXPOSE:-127.0.0.1:5432}:5432"