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

400 milliseconds delay using aiohttp #2729

Closed
karamjaber opened this issue Feb 12, 2018 · 8 comments
Closed

400 milliseconds delay using aiohttp #2729

karamjaber opened this issue Feb 12, 2018 · 8 comments
Labels

Comments

@karamjaber
Copy link

Long story short

I'm using hangups python module to build a solution that leverage messages between client and server.
Hangups uses aiohttp, and it seems like that in the following line in aiohttp it takes him up to 400 milliseconds to perform it:

session.request(method,url,param=param,headers=headers, data=data,proxy=None)
Which eventually calls the function _request in aiohttp\client which calls _wrap_create_connection in aiohttp\connector.py .
The line that causes the delay is

return (yield from self_loop.create_connection(*args,**kwargs))

In connector.py.

Expected behaviour

The maximum time to be less than 50 milliseconds

Actual behaviour

The time it takes can reach 400 milliseconds

Steps to reproduce

run send_message.py under hangups/exampels : ( https://github.com/tdryer/hangups )

Put timer before and after the command

return (yield from self_loop.create_connection(*args,**kwargs))
https://github.com/tdryer/hangups

Your environment

aiohttp version: 2.3.10

 IMPORTANT: aiohttp is both server framework and client library.
 For getting rid of confusing please put 'server', 'client' or 'both'
 word here.
 --> both
@asvetlov
Copy link
Member

You see DNS resolving and TCP connection establishment timeout, aiohttp has no special sleeps for it.

The time can be huge, it depends on client node, server and network between.
I don't see how to fit in 50 ms if, say, your network is slow.

P.S.
After upgrading to aiohttp 3.0 you can use client tracing for timeout measurement, no need for patching aiohttp code anymore.

@karamjaber
Copy link
Author

My network speed is over 100MBs which I assume is fast enough.
So, If I understand right, This is something related to DNS resolving and it can't be improved?

@webknjaz
Copy link
Member

@karamjaber you could deploy a caching DNS in your network or locally next to the app. Have you tried analysing your network traffic by dumping it via tcpdump (viewable via Wireshark, for example)?

@karamjaber
Copy link
Author

As far as I know, I think that Windows does a caching DNS and that's why I don't need to implement it by myself.

@asvetlov
Copy link
Member

Anyway I'm going to close the issue.
Reports like "something is slow on my local machine" are helpless

@karamjaber
Copy link
Author

Tried it on 3 different machines in 3 different networks.
Same behavior.

@webknjaz
Copy link
Member

Still no traffic dump or at least a distilled reproducible example.
/fortune_teller_mode off

@lock
Copy link

lock bot commented Oct 28, 2019

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.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants