Skip to main content

Display Helm Chart Values

1. Improve Resource Allocation

  • You can improve the performance of Dify by adjusting the resource allocation for services in the Helm chart values file.
  • You can increase these values based on your environment and available resources.
  • Recommended configuration for each component:
Notes:
  • API: Scale replicas horizontally as needed
  • Worker: Scale replicas horizontally as needed (if there are many files to upload)
  • Sandbox: Scale replicas horizontally as needed (if there are many compute tasks)
    • maxWorkers: 4 (number of worker processes)
    • workerTimeout: 15 (call timeout)
Configuration Example:

2. Improve External PostgreSQL Performance

2.1 Calculate Database Maximum Connections

When configuring the database, you need to calculate the required maximum connections using the following formula:
Parameters:
  • SQLALCHEMY_POOL_SIZE: Database connection pool size per worker
  • SQLALCHEMY_MAX_OVERFLOW: Maximum additional connections when pool overflows
  • API Workers: API service’s serverWorkerAmount
  • Worker Workers: Worker service’s celeryWorkerAmount
Calculation Example: Assuming the following configuration:
  • API: replicas=6, serverWorkerAmount=1
  • Worker: replicas=2, celeryWorkerAmount=1
  • SQLALCHEMY_POOL_SIZE=100
  • SQLALCHEMY_MAX_OVERFLOW=150
The maximum connections would be:
It is recommended to reserve 20-30% headroom based on the calculation result to handle traffic spikes. In the above example, set max_connections to 2400-2600.

2.2 Complete Configuration Example

3. Performance Monitoring Recommendations

3.1 Key Metrics

Monitor the following metrics to ensure the system is running well: Database Connections:
  • Current active connections
  • Connection pool utilization
  • Requests waiting for connections
Resource Usage:
  • CPU utilization (recommended to keep below 70%)
  • Memory utilization (recommended to keep below 80%)
  • Disk I/O
Application Performance:
  • API response time
  • Worker task queue length
  • Task execution time

3.2 Common Performance Bottlenecks