I have an installation of ERPNext using docker and the server keeps timing out even though less than 10 people uses it. Upon looking at docker stats the backend container is using 100% of CPU. Any advice on what I could do to sort it out?
How much memory and how many cores does your system have? If it’s constantly using 100% of resources, most probably you need to upgrade your system specs.
It is hosted on a digital ocean droplet with these specs:
8 vCPUs
16gb ram
160gb ssd
This was upgrade from 8gb ram after I first noticed the problem. The problem still persists after the upgrade
You’ll have to check what the backend is doing that’s causing 100% cpu usage.
Try GitHub - benfred/py-spy: Sampling profiler for Python programs
I couldn’t get py-spy to work but upon checking with htop it shows Gunicorn to be the process with high CPU usage. I currently only have 2 workers assigned to Gunicorn. Could you point me a way to increase the Gunicorn workers when using docker frappe? I have tried through common site config file but it does not work.
In frappe docker you change the gunicorn worker count inside images/worker/Dockerfile
You have to build the image after changing the worker count
it’s just a CMD
you can override it at runtime in compose as command
array.
e.g. overriden here:
As @revant_one said, you can add the command to the compose override file for custom applications as given below
services:
configurator:
image: custom_app/worker:latest
backend:
image: custom_app/worker:latest
command: ["/home/frappe/frappe-bench/env/bin/gunicorn",
"--bind=0.0.0.0:8000",
"--threads=4",
"--workers=5",
"--worker-class=gthread",
"--worker-tmp-dir=/dev/shm",
"--timeout=120",
"--preload",
"frappe.app:application"]
frontend:
image: custom_app/nginx:latest
queue-short:
image: custom_app/worker:latest
queue-default:
image: custom_app/worker:latest
queue-long:
image: custom_app/worker:latest
scheduler:
image: custom_app/worker:latest