-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Fixed] [PBKAC] Requests on dropped connections are always fulfilled #2783
Comments
Your test snippet looks incorrect because of blocking |
IMHO the req/sec reached are pretty aligned with the CPU cost of the handler, almost matches 100%. |
If I change the
on
I still get 510 requests being fulfilled. If the number of connections/threads of the load test are increased, the number of requests that are fulfilled at the end of load test keeps increasing and the server keeps on and on for quite a while... |
Let me add some more details (I'm working on the same task). Running the load test for 1 minute with @asvetlov you mentioned informing aiohttp about connections closing. Is there a way to do that? |
You should not do blocking calls in asyncio coroutines, the rule is simple, obvious and has no exceptions. |
The callbacks that are pending to be executed to inform that a connection has been closed will be executed after the handler, at least for this example, so you can not try to circumvent that issue making some explicit connection check. Will be nice to check it empirically but its what my gut feeling says. Once said that, in other cases where you have real IO within your handler, that should give the chance to the close connection callback to cancel the task that is being executed [1] [1] https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web_protocol.py#L201 |
@asvetlov Thank you so much for pointing me in the right direction Thanks a lot for the prompt responses! For posteriority:
produces
and the server stops doing work immediately after the load test stops. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Long story short
Requests to the
web.Application
are answered even if the clients already dropped their connections before the web handlers are started.It is important to fix this because under load the resources are being used for closed connections instead of serving the ones that are currently open.
Expected behaviour
I would expect web handlers to not be executed if their connections are already dropped.
Notice, that I am not talking about connections that are dropped while processing web handlers as discussed in #2098.
Actual behaviour
Web handlers are started for already dropped connections.
Steps to reproduce
on
and observe that most of the requests have sockets that are timing out (191/197) and that the server continues to work past the load test. Fulfilling a total of about 400 requests.
GET / HTTP/1.1
and while this request is waiting, just open another telnet session with a similar request and close it before the first request is completed. You will see that the second request will always be fulfilled, and the web handler will be executed twice.Your environment
aiohttp version: 1fd798b (HEAD -> master)
on macOS 10.13.3 with Python 3.6.4 from Homebrew
The text was updated successfully, but these errors were encountered: