langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
50.04k stars 7.15k forks source link

Uploading PDFs to the knowledge bank can disrupt other users' regular usage #6607

Closed wmcde closed 1 month ago

wmcde commented 3 months ago

Self Checks

Dify version

0.6.15

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I deployed DiFY on a local server using Docker, running on Ubuntu 22 with an Intel Xeon Gold 5320*2 CPU, and 256GB of memory. I encountered an issue where uploading approximately ten PDF files, each roughly 10 megabytes in size (totalling approximately 100 megabytes) to the knowledge base takes a significant amount of time; during this period, other users are unable to access DiFY normally. Upon checking the server, I found that system resource usage was at typical levels; only a few CPU cores were at 100% utilization while most remained underutilized. Is there an issue with how DiFY is configured for resource consumption? How should I tweak the configuration settings to maximize server performance and ensure uninterrupted access for all users?

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

dosubot[bot] commented 3 months ago

Hello @wmcde! I'm here to help you with any bugs, questions, or contributions related to DiFY. Let me know how I can assist you!

To address the issue of uploading large PDF files disrupting other users' access in DiFY version 0.6.15, you can tweak several configuration settings to optimize resource usage and improve server performance. Here are the steps you can follow:

  1. Adjust Environment Variables:
    • Increase the number of server workers to handle more concurrent requests.
    • Increase the timeout for request processing to support longer connections.
    • Increase the size of the database connection pool to handle more concurrent database connections.
    • Increase the number of Celery workers to handle background tasks more efficiently.

Here is an example configuration for your docker-compose.yaml file:

services:
  api:
    environment:
      SERVER_WORKER_AMOUNT: "8"  # Adjust based on CPU cores (e.g., 4 cores x 2 + 1)
      GUNICORN_TIMEOUT: "360"  # Increase timeout to support longer connections
      SQLALCHEMY_POOL_SIZE: "50"  # Increase connection pool size if needed
      CELERY_WORKER_AMOUNT: "4"  # Increase the number of Celery workers if needed
      UPLOAD_FILE_SIZE_LIMIT: "100MB"  # Example value, adjust as necessary
      UPLOAD_FILE_BATCH_LIMIT: "10"  # Example value, adjust as necessary
  1. Optimize Resource Allocation:

    • Ensure that your server's resources are fully utilized by adjusting the SERVER_WORKER_AMOUNT based on the number of CPU cores. The recommended formula is CPU core count x 2 + 1.
    • Monitor and adjust the SQLALCHEMY_POOL_SIZE and CELERY_WORKER_AMOUNT based on the workload and server capacity.
  2. Monitor Performance:

    • Continuously monitor the server's performance and resource usage to identify any bottlenecks or underutilized resources. Adjust the configuration settings as needed to ensure optimal performance.

By making these adjustments, you can improve the server's ability to handle large file uploads and maintain uninterrupted access for all users [1][2].

To continue talking to Dosu, mention @dosu.

crazywoola commented 3 months ago

@takatost Could you take a look at this one?