Skip to content

aiohttp client is slow when large number of parallel async requests are launched compared to other http clients using threading #5857

Answered by Dreamsorcerer
kaustubh-d asked this question in Q&A
Discussion options

You must be logged in to vote

https://github.com/kaustubh-d/aio-tests-py/blob/main/aiohttp/aiohttp-client.py#L57
Shouldn't total_time_ms be the time taken for asyncio.gather() to complete, rather than the sum of values from individual requests?

When the client code awaits, it could end up running through every other task before returning to complete that original task.
Whereas the threaded code is likely to complete as soon as the request comes in, thus giving you a smaller time, even if the total runtime is longer.
i.e. It's possible that while it takes 65ms for a task to complete, they may all be completed then and it actually only takes 70ms to run everything, while the requests approach might be taking 4ms to comp…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kaustubh-d
Comment options

@Dreamsorcerer
Comment options

@kaustubh-d
Comment options

Answer selected by kaustubh-d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants