Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Switching to aiohttp? #4560

Open
💡 feature
Labels
@mamad0901-sys

Description

@mamad0901-sys

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:

encode/httpx#838

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp