From f2e71c4f51267ab29e21fed6293a0753e45ad71c Mon Sep 17 00:00:00 2001 From: Sean Keane Date: Wed, 11 Sep 2024 20:35:17 -0500 Subject: [PATCH] Adding docker resources limits and reservations for celery --- .env | 8 ++++++++ docker-compose.dev.yml | 8 ++++++++ docker-compose.yml | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/.env b/.env index f5d282d0c..65ab7cfaa 100644 --- a/.env +++ b/.env @@ -35,3 +35,11 @@ MIN_CONCURRENCY=10 DJANGO_SUPERUSER_USERNAME=rengine DJANGO_SUPERUSER_EMAIL=rengine@example.com DJANGO_SUPERUSER_PASSWORD=Sm7IJG.IfHAFw9snSKv + +# +# Docker Resource Limits +# +CELERY_MEM_LIMIT=8gb +CELERY_CPU_LIMIT=2 +CELERY_CPU_RESERVE=0.50 +CELERY_MEM_RESERVE=1gb \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 29f8a3c8f..9ec022b88 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -26,6 +26,14 @@ services: restart: always entrypoint: /usr/src/app/celery-entrypoint.sh # command: watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --autoscale=10,0 -l INFO + deploy: + resources: + limits: + cpus: ${CELERY_CPU_LIMIT} + memory: ${CELERY_MEM_LIMIT} + reservations: + cpus: ${CELERY_CPU_RESERVE} + memory: ${CELERY_MEM_RESERVE} volumes: - ./web:/usr/src/app - github_repos:/usr/src/github diff --git a/docker-compose.yml b/docker-compose.yml index 141bf724e..700effdea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,6 +27,14 @@ services: restart: always entrypoint: /usr/src/app/celery-entrypoint.sh # command: celery -A reNgine worker --autoscale=${MAX_CONCURRENCY},${MIN_CONCURRENCY} -l INFO + deploy: + resources: + limits: + cpus: ${CELERY_CPU_LIMIT} + memory: ${CELERY_MEM_LIMIT} + reservations: + cpus: ${CELERY_CPU_RESERVE} + memory: ${CELERY_MEM_RESERVE} volumes: - ./web:/usr/src/app - github_repos:/usr/src/github