Skip to content

add max_connection for asgi#3511

Open
monster-anshu wants to merge 2 commits intobenoitc:masterfrom
monster-anshu:max_connection_asgi
Open

add max_connection for asgi#3511
monster-anshu wants to merge 2 commits intobenoitc:masterfrom
monster-anshu:max_connection_asgi

Conversation

@monster-anshu
Copy link
Copy Markdown

No description provided.

@benoitc benoitc self-requested a review February 18, 2026 09:07
@benoitc benoitc self-assigned this Feb 18, 2026
Comment thread gunicorn/asgi/protocol.py
# A connection may arrive between the server accepting and the
# worker reacting to a capacity change. Reject it with 503.
if self.worker.nr_conns > self.worker.worker_connections:
self._reject_over_limit(transport)
Copy link
Copy Markdown

@andersio andersio Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this approach will make it into a release, I hope the 503 hard reject is an opt-in behaviour (i.e., it is a soft limit and slight oversubscribing can be allowed). Alternatively, gunicorn may do this directly on socket.accept to backpressure into the kernel, such that this hard reject can be eliminated.

Responding 503 intermittently is not always desirable (see Uvicorn's --limit-concurrency Kludex/uvicorn#1817), especially when the connection could have been backlogged via backpressure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants