Skip to content

Enable gunicorn's reuse_port in production #248

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

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

edmorley
Copy link
Member

@edmorley edmorley commented Jan 16, 2025

This causes gunicorn to set SO_REUSEPORT on the listening socket, which helps ensure better request distribution between gunicorn workers and thus better performance.

We don't enable this in development, since it makes it harder to notice when duplicate gunicorn processes have accidentally been launched (eg in different terminals), since the "address already in use" error no longer occurs.

See:
https://docs.gunicorn.org/en/stable/settings.html#reuse-port
benoitc/gunicorn#2938
https://lwn.net/Articles/542629/

GUS-W-17614363.

This causes gunicorn to set `SO_REUSEPORT` on the listening
socket, which helps ensure better request distribution between
gunicorn workers and thus better performance.

We don't enable this in development, since it makes it harder to
notice when duplicate gunicorn processes have accidentally been
launched (eg in different terminals), since the "address already in use"
error no longer occurs.

See:
https://docs.gunicorn.org/en/stable/settings.html#reuse-port
benoitc/gunicorn#2938
https://lwn.net/Articles/542629/
@edmorley edmorley self-assigned this Jan 16, 2025
@edmorley edmorley requested a review from a team as a code owner January 16, 2025 14:08
@edmorley edmorley removed the request for review from a team January 16, 2025 14:08
@heroku heroku bot temporarily deployed to getting-star-edmorley-g-xx84zo January 16, 2025 14:08 Inactive
@edmorley edmorley merged commit 6d60400 into main Jan 16, 2025
1 check passed
@edmorley edmorley deleted the edmorley/gunicorn-reuse-port branch January 16, 2025 14:11
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