Feature: Consider gunicorn optimisations for Docker
I noticed some significant performance "blocks" when running Mayan on AWS inside docker.
Without docker it wasn't an issue, but with docker gunicorn would hang for 30 seconds-2 minutes during browsing documents waiting for image cache to be generated. Although I had 5 workers running on a 4 vCPU box it was as if only 1 worker was being used and pdftoppm was causing gunicorn to hang completely for all requests.
Did some digging and discovered https://pythonspeed.com/articles/gunicorn-in-docker/ which lists some potential causes.
Specifically: the gunicorn heartbeat file. On bare metal this often ends up in a tmpfs but inside docker ends up in the containers /tmp on overlay. The gunicorn faq suggests this can cause huge performance problems when using an AWS EBS (which is what I'm doing). The workaround is to add --worker-tmp-dir /dev/shm to the gunicorn startup so it's guarenteed to end up in a tmpfs/in memory fs instead of the overlayfs.
I also have a suspicion that the tmp image generation is halting IO while a sync type worker is being used, but switching to /dev/shm for the Gunicorn heartbeat resulted in a significant improvement for me (which would make sense as the image generation was blocking IO) so we might want to consider looking into this as a change for running Mayan with Docker.