Try ERPNext Buy Support Partners Foundation

Upgrade to Gunicorn 20.0.4?

I did the following enhancements to Gunicorn:

  1. Upgraded gunicorn to 20.0.04 (Current version is 19.10.0)
  2. Added the thread parameters to gunicorn at supervisor.conf to improve efficiency of gunicorn workers
  • Threads: --threads 10 (recommended value is 2 to 4 num_cores x 2.
    (Note: -w 4 (recommended gunicorn value is 2 x num_cores + 1)
  1. Assigned the gunicorn heartbeat filesystem to memory based instead of disk-based (Ubuntu 18).
  • –worker-tmp-dir /dev/shm

I am happy to note that there is a noticeable snappiness in the response of ERPNext.
(This is only for those who understand the production mode well, because messing with generated conf files may get messy if you don’t know your way.)

2 Likes

It is similar in Docker https://github.com/frappe/frappe_docker/blob/f1d072d4656920fd733fc6a4a58ce305e1123a98/build/common/worker/docker-entrypoint.sh#L99

gunicorn -b 0.0.0.0:$FRAPPE_PORT \
      --worker-tmp-dir /dev/shm \
      --threads=4 \
      --workers $WORKERS \
      --worker-class=gthread \
      --log-file=- \
      -t 120 frappe.app:application --preload

More: https://pythonspeed.com/articles/gunicorn-in-docker/

Yes. Docker has a Gunicorn heartbeat problem like Ubuntu. It is good that this is considered in Frappe’s Docker config
It may be good for Frappe to have gunicorn_threads and gunicorn_worker_class as additional parameters, like the line you show in Docker config.