# How can I change the number of gunicorn workers in Tutor

**URL:** <https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887>\
**Category:** Tutor Help\
**Created:** [May 14, 2025, 7:06am UTC](https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887 "2025-05-14T07:06:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlorianOver](https://avatars.discourse-cdn.com/v4/letter/f/a9adbd/32.png) [@FlorianOver](https://discuss.openedx.org/u/FlorianOver)\
**Post date:** [May 14, 2025, 7:06am UTC](https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887/1 "2025-05-14T07:06:19Z")

</div>

Hi,  
i am running Tutor in an LXC Container with 6GB of RAM.  
This leads to situations where Tutor is using all the RAM and CPU.  
I would like to reduce the number of gunicorn workers.  
How can this be achieved?  
Are there other ways to reduce the memory consumption?

Kind regards  
Florian

---

<div class="post-metadata">

**Author:** ![FlorianOver](https://avatars.discourse-cdn.com/v4/letter/f/a9adbd/32.png) [@FlorianOver](https://discuss.openedx.org/u/FlorianOver)\
**Post date:** [May 14, 2025, 9:37am UTC](https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887/2 "2025-05-14T09:37:55Z")

</div>

I figured out that the problem is the amount of celery workers.  
Is there a way to set it in the configuration?

---

<div class="post-metadata">

**Author:** ![FlorianOver](https://avatars.discourse-cdn.com/v4/letter/f/a9adbd/32.png) [@FlorianOver](https://discuss.openedx.org/u/FlorianOver)\
**Post date:** [May 14, 2025, 9:41am UTC](https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887/3 "2025-05-14T09:41:17Z")

</div>

The underlying issue is that the amount of cpus of the host is 20 but the amount of cpus of the container is 2.

---

<div class="post-metadata">

**Author:** ![joel.edwards](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/joel.edwards/32/3193_2.png) [@joel.edwards](https://discuss.openedx.org/u/joel.edwards)\
**Post date:** [May 14, 2025, 10:07am UTC](https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887/4 "2025-05-14T10:07:18Z")

</div>

When I first started setting up Tutor I also had a similar issue with resources, if you have too many CPU cores then it will overload the RAM if you don’t have enough. I first tried with 8 cores and 8GB RAM but that was just getting eaten up very fast. Re-building images also had a tendency to fail. I ended up settling on 16GB RAM and 3 cores which has been rock solid since.

I haven’t actually tried this before, not sure if it’s even still a valid configuration - but maybe it helps, there’s a config you can specify the maximum workers. The default ([source](https://discuss.openedx.org/t/open-edx-high-memory-usage/4482/2)) is 4 \* the number of cores for the LMS, and 2 \* the number of cores for the CMS, meaning on a 20-core system you have 120 workers total

> <https://github.com/edx/configuration/blob/master/playbooks/roles/edxapp/defaults/main.yml#L657-L662>

---

<div class="post-metadata">

**Author:** ![twlichty](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/twlichty/32/3653_2.png) [@twlichty](https://discuss.openedx.org/u/twlichty)\
**Post date:** [May 14, 2025, 10:16am UTC](https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887/5 "2025-05-14T10:16:00Z")

</div>

You can use:  
OPENEDX\_LMS\_UWSGI\_WORKERS  
OPENEDX\_CMS\_UWSGI\_WORKERS

See the docs in tutor:

> **[Configuration and customisation — Tutor documentation](https://docs.tutor.edly.io/configuration.html#open-edx-customisation)**

---

<div class="post-metadata">

**Author:** ![FlorianOver](https://avatars.discourse-cdn.com/v4/letter/f/a9adbd/32.png) [@FlorianOver](https://discuss.openedx.org/u/FlorianOver)\
**Post date:** [May 14, 2025, 2:03pm UTC](https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887/6 "2025-05-14T14:03:56Z")

</div>

Hi I found the following ticket now:

> <https://github.com/overhangio/tutor/issues/1126>
>
> \*\*Bug description\*\*
> 
> 
> 
> 
> The normal execution of the celery workers, lms-wor…ker and cms-worker services, consumes too much memory by default.
> Tested on my tutor local, but I'm assuming that with tutor dev is the same.
> By default the celery start 1 process by each CPU. If the deployed laptop or server has multiple CPU architecture, then the celery will launch multiple OS processes.
> Each celery OS process consumes memory.
> This makes more CPUs you have, more memory RAM the celery worker will consume.
> The problem that I see is that on a deployed server, the operator probably don't want this magic, and want to control how much celery OS process each container/pod will start and consequently how much memory each container/pods will consume.
> 
> \*\*How to reproduce\*\*
> 
> 
> 
> 
> 
> Run a tutor local environment and see how much RAM your celery workers is consuming. 
> On 16 CPU server/laptop an idle environment each container lms/cms-worker consumes \>2GB RAM per container.
> 
> If you add \`--concurrency=1\` to the lms/cms-worker command an idle tutor local env uses \<300MB per container.
> 
> \*\*Environment\*\*
> 
> tutor, version 14.2.3
> But this applies also to newer version.
> 
> \*\*Solution (my opinion)\*\*
> 1. Add a way to parameterize the concurrency on each worker, ex: \`--concurrency={{ LMS\_WORKER\_CELERY\_CONCURRENCY }}\`
> 2. Each celery worker by default should always consume the minimum memory, so it should defaults to just \`1\`.
> 3. In my opinion there should be an easy way to customize both celery commands, lms-worker and cms-worker. Ex. adding the \`--prefetch-multiplier=1 --without-gossip --without-mingle\`

Setting the configuration value `--concurrency=1` is exactly what I need.

---

<div class="post-metadata">

**Author:** ![FlorianOver](https://avatars.discourse-cdn.com/v4/letter/f/a9adbd/32.png) [@FlorianOver](https://discuss.openedx.org/u/FlorianOver)\
**Post date:** [May 15, 2025, 9:19am UTC](https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887/7 "2025-05-15T09:19:07Z")

</div>

I found a solution by creating a plugin with the following content:

```auto
from tutor import hooks

hooks.Filters.CMS_WORKER_COMMAND.add_items(
    [
        "--concurrency=1"
    ]
)

hooks.Filters.LMS_WORKER_COMMAND.add_items(
    [
        "--concurrency=1"
    ]
)

```

---

<div class="post-metadata">

**Author:** ![martinanderson](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/martinanderson/32/8313_2.png) [@martinanderson](https://discuss.openedx.org/u/martinanderson)\
**Post date:** [May 15, 2025, 2:26pm UTC](https://discuss.openedx.org/t/how-can-i-change-the-number-of-gunicorn-workers-in-tutor/15887/8 "2025-05-15T14:26:09Z")

</div>

Hi Florian,

In order to reduce Tutor’s memory and CPU usage in your LXC container, you can reduce the number of Gunicorn workers. This is done by setting the WORKERS environment variable in your config.yml or by using tutor config save --set CMS\_WORKERS= and LMS\_WORKERS= as needed. Reducing workers reduces concurrent processes and resource use. Additionally, you may consider turning off plugins you don’t use, reducing Docker service replicas, and limiting service restart policies.

You can monitor process memory and CPU usage with htop, or docker stats to get metrics you can use to finish optimizing to suit your needs.
