Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure gunicorn with 2 gevent workers #4

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

lorenyu
Copy link
Collaborator

@lorenyu lorenyu commented Dec 11, 2023

Ticket

N/A

Changes

  • Set num workers to 2
  • Set guincorn worker class to gevent
  • Reset memory back to infra template's default of 512 mb

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant