Advanced Configuration
Performance Tuning
Display Helm Chart Values
1. Improve Resource Allocation
- You can improve the performance of Dify by adjusting the resource allocation for
api
,worker
, andplugin_daemon
services in the Helm chart values file. - You can increase these values based on your environment and available resources.
2. Improve External postgres
Performance
- If you are using an external Postgres database, you can improve the performance by adjusting the following parameters in the
postgresql.conf
file:max_connections
: Set to2000
or higher based on your environment.
3. api
and worker
Services
- You can set the number of workers based on your environment and available resources.
-
celeryWorkerAmount
: The number ofCelery
workers forworker
service.- How to calculate:
- If you are in production environment, you can set it to
number of cpu cores
. - If you are in testing environment, you can set it to
1
to save resources.
- If you are in production environment, you can set it to
- Reference: https://docs.celeryq.dev/en/stable/reference/cli.html#cmdoption-celery-worker-c
- How to calculate:
-
serverWorkerAmount
: The number ofGunicorn
workers forapi
service.We recommend setting the number of workers to
1
. If you set it to a value greater than1
, you need to ensure that yourapi
service can handle the increased load.- How to calculate:
- You can set it to
number of cpu cores x 2 + 1
.
- You can set it to
- Reference: https://docs.gunicorn.org/en/stable/design.html#how-many-workers
- How to calculate: