flask-gunicorn
flask-gunicorn copied to clipboard
multiprocessing.cpu_count() is dangerous in containers
https://github.com/doobeh/flask-gunicorn/blob/cb571ff9a08e1ac03b66f9a32bbe99dd78c46aca/flask_gunicorn.py#L26
Due to https://bugs.python.org/issue36054, when the above is run inside a container that has been allocated (say) a single core and 512 MB of RAM on a machine with 64 cores, flask-gunicorn thinks it has 64 cores instead of just 1, and spawns 129 workers. This is way more than the container has resources for, and ends up causing out of memory crashes.
Ref: https://github.com/benoitc/gunicorn/issues/2028 (where this is being propagated from upstream)