Configure gunicorn with 2 gevent workers #4
+189
−46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket
N/A
Changes
Context
We recently hit more deploys where the service would never reach a healthy state. Upon further investigation, this article (https://pythonspeed.com/articles/gunicorn-in-docker/) suggests that when running gunicorn in a Docker context, the number of workers should not scale with the number of CPUs. The article also
A few other articles and gunicorn's own docs recommend that the gevent worker class is used instead of the default sync (synchronous) worker class. This allows things like database calls or network class to allow the worker to switch to another thread while waiting on I/O.
https://docs.gunicorn.org/en/latest/design.html,
https://medium.com/@danieldng/use-gevent-when-your-gunicorn-worker-is-waiting-for-data-180efef96367,
https://stackoverflow.com/questions/69372896/gunicorn-with-gevent-performance-gain
Testing
Deploy from this branch