You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If your container has been allocated (say) a single core and 512 MB of RAM on a machine with 64 cores, multiprocessing.cpu_count() thinks it has 64 cores instead of just 1, and you end up spawning 129 workers. This is way more than the container has resources for, and ends up causing out of memory crashes.
I ran into this issue with too many workers being spawned in a docker container on kubernetes, and my application would be in a constant CrashLoopBackoff state.
I've modified the default gunicorn_config.py to assign cores to an optional AVAILABLE_CORES variable; This is set when I define the number of cpus for the container.
As discussed here:
I ran into this issue with too many workers being spawned in a docker container on kubernetes, and my application would be in a constant CrashLoopBackoff state.
Debug logs
Docker Image
Relevant Line of Code
uvicorn-gunicorn-docker/docker-images/gunicorn_conf.py
Line 21 in 622470e
Solution
I've modified the default
gunicorn_config.py
to assigncores
to an optionalAVAILABLE_CORES
variable; This is set when I define the number of cpus for the container.The text was updated successfully, but these errors were encountered: