Skip to content

Commit 1dd4b5a

Browse files
committed
feat: Celery worker concurrency setting
This allows the user to configure how many Celery workers are spawned independently of how many CPUs there are in the system. The default is to spawn as many workers as there are CPUs, which in some cases can consume too many resources. (The setting should be particularly useful to people running Tutor for development on Linux machines, where reducing the concurrency to "1" can reduce RAM usage significantly.)
1 parent 13c420c commit 1dd4b5a

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Feature] Allow the user to configure Celery worker concurrency. (by @arbrandes)

docs/configuration.rst

+5
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ This defines the version that will be pulled from just the Open edX platform git
149149

150150
By default, there are 2 `uwsgi worker processes <https://uwsgi-docs.readthedocs.io/en/latest/Options.html#processes>`__ to serve requests for the LMS and the CMS. However, each worker requires upwards of 500 Mb of RAM. You should reduce this value to 1 if your computer/server does not have enough memory.
151151

152+
- ``OPENEDX_LMS_CELERY_WORKERS`` (default: ``"0"``)
153+
- ``OPENEDX_CMS_CELERY_WORKERS`` (default: ``"0"``)
154+
155+
This sets the number of Celery workers at startup. Defaults to the number of CPUs detected on the system (represented by "0"). If your system's RAM is limited, you may need to set this to a low integer value in order to conserve it. (On development deployments, it is suggested to use "1" for both.)
156+
152157
- ``OPENEDX_CELERY_REDIS_DB`` (default: ``0``)
153158
- ``OPENEDX_CACHE_REDIS_DB`` (default: ``1``)
154159

tutor/templates/config/defaults.yml

+2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ OPENEDX_AWS_ACCESS_KEY: ""
5454
OPENEDX_AWS_SECRET_ACCESS_KEY: ""
5555
OPENEDX_CACHE_REDIS_DB: 1
5656
OPENEDX_CELERY_REDIS_DB: 0
57+
OPENEDX_CMS_CELERY_WORKERS: 0
5758
OPENEDX_CMS_UWSGI_WORKERS: 2
59+
OPENEDX_LMS_CELERY_WORKERS: 0
5860
OPENEDX_LMS_UWSGI_WORKERS: 2
5961
OPENEDX_MYSQL_DATABASE: "openedx"
6062
OPENEDX_MYSQL_USERNAME: "openedx"

tutor/templates/k8s/deployments.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ spec:
141141
containers:
142142
- name: cms-worker
143143
image: {{ DOCKER_IMAGE_OPENEDX }}
144-
args: ["celery", "--app=cms.celery", "worker", "--loglevel=info", "--hostname=edx.cms.core.default.%%h", "--max-tasks-per-child", "100", "--exclude-queues=edx.lms.core.default"]
144+
args: ["celery", "--app=cms.celery", "worker", "--loglevel=info", "--hostname=edx.cms.core.default.%%h", "--concurrency={{ OPENEDX_CMS_CELERY_WORKERS }}", "--max-tasks-per-child", "100", "--exclude-queues=edx.lms.core.default"]
145145
env:
146146
- name: SERVICE_VARIANT
147147
value: cms
@@ -250,7 +250,7 @@ spec:
250250
containers:
251251
- name: lms-worker
252252
image: {{ DOCKER_IMAGE_OPENEDX }}
253-
args: ["celery", "--app=lms.celery", "worker", "--loglevel=info", "--hostname=edx.lms.core.default.%%h", "--max-tasks-per-child=100", "--exclude-queues=edx.cms.core.default"]
253+
args: ["celery", "--app=lms.celery", "worker", "--loglevel=info", "--hostname=edx.lms.core.default.%%h", "--concurrency={{ OPENEDX_LMS_CELERY_WORKERS }}", "--max-tasks-per-child=100", "--exclude-queues=edx.cms.core.default"]
254254
env:
255255
- name: SERVICE_VARIANT
256256
value: lms

tutor/templates/local/docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ services:
158158
environment:
159159
SERVICE_VARIANT: lms
160160
DJANGO_SETTINGS_MODULE: lms.envs.tutor.production
161-
command: celery --app=lms.celery worker --loglevel=info --hostname=edx.lms.core.default.%%h --max-tasks-per-child=100 --exclude-queues=edx.cms.core.default
161+
command: celery --app=lms.celery worker --loglevel=info --hostname=edx.lms.core.default.%%h --concurrency={{ OPENEDX_LMS_CELERY_WORKERS }} --max-tasks-per-child=100 --exclude-queues=edx.cms.core.default
162162
restart: unless-stopped
163163
volumes:
164164
- ../apps/openedx/settings/lms:/openedx/edx-platform/lms/envs/tutor:ro
@@ -177,7 +177,7 @@ services:
177177
environment:
178178
SERVICE_VARIANT: cms
179179
DJANGO_SETTINGS_MODULE: cms.envs.tutor.production
180-
command: celery --app=cms.celery worker --loglevel=info --hostname=edx.cms.core.default.%%h --max-tasks-per-child 100 --exclude-queues=edx.lms.core.default
180+
command: celery --app=cms.celery worker --loglevel=info --hostname=edx.cms.core.default.%%h --concurrency={{ OPENEDX_CMS_CELERY_WORKERS }} --max-tasks-per-child 100 --exclude-queues=edx.lms.core.default
181181
restart: unless-stopped
182182
volumes:
183183
- ../apps/openedx/settings/lms:/openedx/edx-platform/lms/envs/tutor:ro

0 commit comments

Comments
 (0)