Skip to content

Commit b44aee8

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 67174ae commit b44aee8

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-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

+11
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,17 @@ This configuration parameter sets the name of the MySQL Database to be used by t
180180

181181
This configuration parameter sets the username associated with the MySQL Database.
182182

183+
Celery workers
184+
~~~~~~~~~~~~~~
185+
186+
- ``LMS_WORKER_CONCURRENCY`` (default: ``"0"``)
187+
188+
This sets the number of LMS celery workers at startup. Defaults to the number of CPUs detected on the system (represented by "0").
189+
190+
- ``CMS_WORKER_CONCURRENCY`` (default: ``"0"``)
191+
192+
This sets the number of LMS celery workers at startup. Defaults to the number of CPUs detected on the system (represented by "0").
193+
183194
CMS OAUTH2 SSO
184195
~~~~~~~~~~~~~~
185196

tutor/templates/config/defaults.yml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CADDY_HTTP_PORT: 80
99
CMS_HOST: "studio.{{ LMS_HOST }}"
1010
CMS_OAUTH2_KEY_SSO: "cms-sso"
1111
CMS_OAUTH2_KEY_SSO_DEV: "cms-sso-dev"
12+
CMS_WORKER_CONCURRENCY: 0
1213
CONTACT_EMAIL: "contact@{{ LMS_HOST }}"
1314
DEV_PROJECT_NAME: "{{ TUTOR_APP }}_dev"
1415
DOCKER_COMPOSE_VERSION: "3.7"
@@ -42,6 +43,7 @@ JWT_COMMON_SECRET_KEY: "{{ OPENEDX_SECRET_KEY }}"
4243
K8S_NAMESPACE: "openedx"
4344
LANGUAGE_CODE: "en"
4445
LMS_HOST: "www.myopenedx.com"
46+
LMS_WORKER_CONCURRENCY: 0
4547
LOCAL_PROJECT_NAME: "{{ TUTOR_APP }}_local"
4648
MONGODB_AUTH_MECHANISM: ""
4749
MONGODB_AUTH_SOURCE: "admin"

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={{ CMS_WORKER_CONCURRENCY }}", "--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={{ LMS_WORKER_CONCURRENCY }}", "--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={{ LMS_WORKER_CONCURRENCY }} --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={{ CMS_WORKER_CONCURRENCY }} --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)