- Notifications
You must be signed in to change notification settings - Fork5.7k
Description
What kind of feature are you missing? Where do you notice a shortcoming of PTB?
Performance Improvement
Hi
Thanks for this great project.
Are there any plans to switch to aiohttp in future?
Describe the solution you'd like
It seems like aiohttp performs faster in async projects (specially the ones with high volumes of traffic).
There are some benchmarks that prove this:
For example this one from 2020 suggests that aiohttp performs faster in both single-request and multiple-requests sessions:
The code used in the test above seemed very simple and logical, so I reran it with the latest versions of both modules on my own machine and got the same results in favor of aiohttp:
aiohttp
$ wrk http://localhost:8000/aiohttp/sessionRunning 10s test @ http://localhost:8000/aiohttp/session 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 20.06ms 2.86ms 45.07ms 94.14% Req/Sec 250.26 23.66 303.00 77.00% 4989 requests in 10.01s, 711.32KB readRequests/sec: 498.41Transfer/sec: 71.06KB
httpx
$ wrk http://localhost:8000/httpx/sessionRunning 10s test @ http://localhost:8000/httpx/session 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 54.59ms 28.80ms 163.58ms 79.85% Req/Sec 92.11 19.31 140.00 68.50% 1839 requests in 10.01s, 262.20KB readRequests/sec: 183.67Transfer/sec: 26.19KB
Therefore httpx is abouttwo to three times slower when re-using a session for requests. My results too showed even more slower performance of httpx in single-request sessions (which is not very important in this project)
Other than speed differences, it might even suggest that aiohttp uses less resources like CPU too (maybe).
Thanks
Describe alternatives you've considered
Using aiohttp
Additional context
No response