aiohttp client is slow when large number of parallel async requests are launched compared to other http clients using threading #5857
-
aiohttp client is slow when large number of parallel async requests are launched compared to other http clients using threading. Sample code to reproduce:
Test run report example- https://github.com/kaustubh-d/aio-tests-py/blob/main/reports/report-1.md Note
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
https://github.com/kaustubh-d/aio-tests-py/blob/main/aiohttp/aiohttp-client.py#L57 When the client code |
Beta Was this translation helpful? Give feedback.
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
await
s, 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…