Increase API workers/ celery workers #954

Closed
opened 2026-02-21 17:29:11 -05:00 by yindo · 3 comments
Owner

Originally created by @ghost on GitHub (Jan 23, 2024).

Self Checks

Provide a description of the help you need

I Deployed using docker. I that env var can be set to increase API workers and celery workers.

They just same number higher create more workers. Or even more to it. I was sure if do we have to make more API containers? Do you have to change anything for more celery workers?

0 Also what is the exact difference intype of workers

Originally created by @ghost on GitHub (Jan 23, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to file this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). ### Provide a description of the help you need I Deployed using docker. I that env var can be set to increase API workers and celery workers. They just same number higher create more workers. Or even more to it. I was sure if do we have to make more API containers? Do you have to change anything for more celery workers? 0 Also what is the exact difference intype of workers
yindo added the 💪 enhancement📚 documentation labels 2026-02-21 17:29:11 -05:00
yindo closed this issue 2026-02-21 17:29:11 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 23, 2024):

🤖

Hey there @vontainment! Good to see you back here again. Let's dive into this issue together, shall we? 🏊‍♂️

To increase the number of API and Celery workers in your dify deployment using Docker, you can use Docker Compose's scale command. For instance, if you want to scale the API service to 3 instances and the worker service to 5 instances, you can use the following command:

docker-compose up --scale api=3 --scale worker=5

The api service in the Docker Compose file is responsible for running the API server of the dify application. It handles incoming HTTP requests and performs operations such as reading from or writing to the database, interacting with other services, etc.

On the other hand, the worker service is a Celery worker that processes tasks in the background. These tasks can be anything that doesn't need to be executed immediately as part of a request-response cycle, such as sending emails, generating reports, or any other time-consuming operations. By increasing the number of Celery workers, you can process more tasks concurrently.

Please note that scaling up the number of workers will also increase the resource usage (CPU, memory, etc.) of your system, so make sure your system has enough resources to handle the increased load.

As for your question about environment variables in the dify Docker configuration that control the number of API and Celery workers, I wasn't able to find any specific environment variables within the repository that would allow you to control the number of workers. However, the number of workers is typically controlled by the application's configuration or the system's resources, not the Docker configuration.

Finally, there doesn't seem to be a limit to the number of API and Celery workers that can be set in the dify Docker configuration. The Docker configuration file provided does not specify a limit to the number of API and Celery workers that can be set. However, you can control the number of workers by scaling the services using Docker Compose's scale command.

I hope this helps! If you have any more questions, feel free to ask.

Sources:

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot[bot] commented on GitHub (Jan 23, 2024): _🤖_ <!-- Greeting --> Hey there @vontainment! Good to see you back here again. Let's dive into this issue together, shall we? 🏊‍♂️ <!-- Answer --> To increase the number of API and Celery workers in your dify deployment using Docker, you can use Docker Compose's scale command. For instance, if you want to scale the API service to 3 instances and the worker service to 5 instances, you can use the following command: ```bash docker-compose up --scale api=3 --scale worker=5 ``` The `api` service in the Docker Compose file is responsible for running the API server of the dify application. It handles incoming HTTP requests and performs operations such as reading from or writing to the database, interacting with other services, etc. On the other hand, the `worker` service is a Celery worker that processes tasks in the background. These tasks can be anything that doesn't need to be executed immediately as part of a request-response cycle, such as sending emails, generating reports, or any other time-consuming operations. By increasing the number of Celery workers, you can process more tasks concurrently. Please note that scaling up the number of workers will also increase the resource usage (CPU, memory, etc.) of your system, so make sure your system has enough resources to handle the increased load. As for your question about environment variables in the dify Docker configuration that control the number of API and Celery workers, I wasn't able to find any specific environment variables within the repository that would allow you to control the number of workers. However, the number of workers is typically controlled by the application's configuration or the system's resources, not the Docker configuration. Finally, there doesn't seem to be a limit to the number of API and Celery workers that can be set in the dify Docker configuration. The Docker configuration file provided does not specify a limit to the number of API and Celery workers that can be set. However, you can control the number of workers by scaling the services using Docker Compose's scale command. I hope this helps! If you have any more questions, feel free to ask. Sources: - [docker/docker-compose.yaml](https://github.com/langgenius/dify/blob/main/docker/docker-compose.yaml) ## Sources - [docker/docker-compose.yaml](https://github.com/langgenius/dify/blob/main/docker/docker-compose.yaml) --- This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
Author
Owner

@ghost commented on GitHub (Jan 23, 2024):

Not sure how credible that answer is...
It's not in the repo but on the website it has these environment variables for containers.

Container Startup Related Configuration
Only effective when starting with docker image or docker-compose.
DIFY_BIND_ADDRESS
API service binding address, default: 0.0.0.0, i.e., all addresses can be accessed.
DIFY_PORT
API service binding port number, default 5001.
SERVER_WORKER_AMOUNT
The number of API server workers, i.e., the number of gevent workers. Formula: number of cpu cores x 2 + 1
Reference: https://docs.gunicorn.org/en/stable/design.html#how-many-workers
SERVER_WORKER_CLASS
Defaults to gevent. If using windows, it can be switched to sync or solo.
GUNICORN_TIMEOUT
Request handling timeout. The default is 200, it is recommended to set it to 360 to support a longer sse connection time.
CELERY_WORKER_CLASS
Similar to SERVER_WORKER_CLASS. Default is gevent. If using windows, it can be switched to sync or solo.
CELERY_WORKER_AMOUNT
The number of Celery workers. The default is 1, and can be set as needed.
@ghost commented on GitHub (Jan 23, 2024): Not sure how credible that answer is... It's not in the repo but on the website it has these environment variables for containers. ``` Container Startup Related Configuration Only effective when starting with docker image or docker-compose. DIFY_BIND_ADDRESS API service binding address, default: 0.0.0.0, i.e., all addresses can be accessed. DIFY_PORT API service binding port number, default 5001. SERVER_WORKER_AMOUNT The number of API server workers, i.e., the number of gevent workers. Formula: number of cpu cores x 2 + 1 Reference: https://docs.gunicorn.org/en/stable/design.html#how-many-workers SERVER_WORKER_CLASS Defaults to gevent. If using windows, it can be switched to sync or solo. GUNICORN_TIMEOUT Request handling timeout. The default is 200, it is recommended to set it to 360 to support a longer sse connection time. CELERY_WORKER_CLASS Similar to SERVER_WORKER_CLASS. Default is gevent. If using windows, it can be switched to sync or solo. CELERY_WORKER_AMOUNT The number of Celery workers. The default is 1, and can be set as needed. ```
Author
Owner

@crazywoola commented on GitHub (Jan 23, 2024):

Not sure how credible that answer is... It's not in the repo but on the website it has these environment variables for containers.

Container Startup Related Configuration
Only effective when starting with docker image or docker-compose.
DIFY_BIND_ADDRESS
API service binding address, default: 0.0.0.0, i.e., all addresses can be accessed.
DIFY_PORT
API service binding port number, default 5001.
SERVER_WORKER_AMOUNT
The number of API server workers, i.e., the number of gevent workers. Formula: number of cpu cores x 2 + 1
Reference: https://docs.gunicorn.org/en/stable/design.html#how-many-workers
SERVER_WORKER_CLASS
Defaults to gevent. If using windows, it can be switched to sync or solo.
GUNICORN_TIMEOUT
Request handling timeout. The default is 200, it is recommended to set it to 360 to support a longer sse connection time.
CELERY_WORKER_CLASS
Similar to SERVER_WORKER_CLASS. Default is gevent. If using windows, it can be switched to sync or solo.
CELERY_WORKER_AMOUNT
The number of Celery workers. The default is 1, and can be set as needed.

Here is the original link

@crazywoola commented on GitHub (Jan 23, 2024): > Not sure how credible that answer is... It's not in the repo but on the website it has these environment variables for containers. > > ``` > Container Startup Related Configuration > Only effective when starting with docker image or docker-compose. > DIFY_BIND_ADDRESS > API service binding address, default: 0.0.0.0, i.e., all addresses can be accessed. > DIFY_PORT > API service binding port number, default 5001. > SERVER_WORKER_AMOUNT > The number of API server workers, i.e., the number of gevent workers. Formula: number of cpu cores x 2 + 1 > Reference: https://docs.gunicorn.org/en/stable/design.html#how-many-workers > SERVER_WORKER_CLASS > Defaults to gevent. If using windows, it can be switched to sync or solo. > GUNICORN_TIMEOUT > Request handling timeout. The default is 200, it is recommended to set it to 360 to support a longer sse connection time. > CELERY_WORKER_CLASS > Similar to SERVER_WORKER_CLASS. Default is gevent. If using windows, it can be switched to sync or solo. > CELERY_WORKER_AMOUNT > The number of Celery workers. The default is 1, and can be set as needed. > ``` Here is the original [link](https://docs.dify.ai/getting-started/install-self-hosted/environments#container-startup-related-configuration)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#954