DIFY API [CRITICAL] WORKER TIMEOUT #4759

Closed
opened 2026-02-21 18:07:54 -05:00 by yindo · 1 comment
Owner

Originally created by @kk-kwok on GitHub (Jul 24, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.15

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

After the DIFY API is run, the following error log often appears, and the web page cannot be opened.

[2024-07-24 06:33:40 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:35)
[2024-07-24 06:33:41 +0000] [1] [ERROR] Worker (pid:35) was sent SIGKILL! Perhaps out of memory?
[2024-07-24 06:33:41 +0000] [39] [INFO] Booting worker with pid: 39

cpu and memory requests and limits

limits:
  cpu: 2
  memory: 8Gi
requests:
  cpu: 2
  memory: 8Gi

api server env

GUNICORN_TIMEOUT=600  # I have tried setting 360, 600, 1200, and 3600, but all have problems.
CELERY_WORKER_AMOUNT=1

api server cpu and memory monitor

dify-api-cpu
dify-api-memory

api version

I have tried from 0.6.8 to the latest version 0.6.15 and still have the same problem.

✔️ Expected Behavior

To solve this problem, access diffify normally

Actual Behavior

No response

Originally created by @kk-kwok on GitHub (Jul 24, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [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 submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.15 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce # After the DIFY API is run, the following error log often appears, and the web page cannot be opened. [2024-07-24 06:33:40 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:35) [2024-07-24 06:33:41 +0000] [1] [ERROR] Worker (pid:35) was sent SIGKILL! Perhaps out of memory? [2024-07-24 06:33:41 +0000] [39] [INFO] Booting worker with pid: 39 # cpu and memory requests and limits ```yaml limits: cpu: 2 memory: 8Gi requests: cpu: 2 memory: 8Gi ``` # api server env ```yaml GUNICORN_TIMEOUT=600 # I have tried setting 360, 600, 1200, and 3600, but all have problems. CELERY_WORKER_AMOUNT=1 ``` # api server cpu and memory monitor ![dify-api-cpu](https://github.com/user-attachments/assets/aec70cec-429c-4db8-9e7e-b58b6ead299f) ![dify-api-memory](https://github.com/user-attachments/assets/56bb83fe-8eec-4410-b268-4d60dbc9b11f) # api version I have tried from 0.6.8 to the latest version 0.6.15 and still have the same problem. ### ✔️ Expected Behavior To solve this problem, access diffify normally ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:07:54 -05:00
yindo closed this issue 2026-02-21 18:07:54 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 24, 2024):

@kk-kwok Hello there! I'm a bot here to help you with any bugs, questions, or contributions you have for the DIFY API. Let's work together to solve the issue you're experiencing.

To resolve the worker timeout issue in the Dify API, you can try the following steps:

  1. Increase Gunicorn Workers and Threads:

    • Adjust the GUNICORN_WORKERS and GUNICORN_THREADS environment variables to better utilize your CPU cores. The recommended formula for GUNICORN_WORKERS is:
      number of cpu cores x 2 + 1
      
    • For GUNICORN_THREADS, you can start with a value like 4 and adjust based on your specific requirements.

    Example configuration:

    GUNICORN_WORKERS=5  # Assuming 2 CPU cores
    GUNICORN_THREADS=4
    
  2. Check for Memory Leaks:

    • Ensure there are no memory leaks in your application code that could be causing the worker processes to consume excessive memory over time.
  3. Optimize Celery Worker Configuration:

    • The default value for CELERY_WORKER_AMOUNT is 1, but you can increase it based on your workload and available resources.
  4. Enable Detailed Logging:

    • Use Dify's observability features to monitor and analyze application logs and performance. This can help you identify specific issues causing the timeouts.
  5. Review Resource Allocation:

    • Ensure that the resource requests and limits are appropriate for your workload. You might need to increase the memory limit if your application requires more memory.
  6. Update to the Latest Version:

    • Make sure you are using the latest version of Dify, as updates may include performance improvements and bug fixes.

By following these steps, you should be able to mitigate the worker timeout issue and improve the performance of your Dify API deployment [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jul 24, 2024): <!-- Greeting --> @kk-kwok Hello there! I'm a bot here to help you with any bugs, questions, or contributions you have for the DIFY API. Let's work together to solve the issue you're experiencing. <!-- Answer --> To resolve the worker timeout issue in the Dify API, you can try the following steps: 1. **Increase Gunicorn Workers and Threads**: - Adjust the `GUNICORN_WORKERS` and `GUNICORN_THREADS` environment variables to better utilize your CPU cores. The recommended formula for `GUNICORN_WORKERS` is: ``` number of cpu cores x 2 + 1 ``` - For `GUNICORN_THREADS`, you can start with a value like 4 and adjust based on your specific requirements. Example configuration: ```yaml GUNICORN_WORKERS=5 # Assuming 2 CPU cores GUNICORN_THREADS=4 ``` 2. **Check for Memory Leaks**: - Ensure there are no memory leaks in your application code that could be causing the worker processes to consume excessive memory over time. 3. **Optimize Celery Worker Configuration**: - The default value for `CELERY_WORKER_AMOUNT` is 1, but you can increase it based on your workload and available resources. 4. **Enable Detailed Logging**: - Use Dify's observability features to monitor and analyze application logs and performance. This can help you identify specific issues causing the timeouts. 5. **Review Resource Allocation**: - Ensure that the resource requests and limits are appropriate for your workload. You might need to increase the memory limit if your application requires more memory. 6. **Update to the Latest Version**: - Make sure you are using the latest version of Dify, as updates may include performance improvements and bug fixes. By following these steps, you should be able to mitigate the worker timeout issue and improve the performance of your Dify API deployment <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/getting-started/install-self-hosted/environments.md)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/docker/.env.example)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4759