Python HTTP clients compared: requests vs httpx vs aiohttp
By the ProxyOnly team · 25 Nov 2026 · 5 min read
A tested comparison of requests, httpx and aiohttp, including a benchmark where the run-to-run noise turned out to be larger than the gap people argue about.
Python has three HTTP clients worth considering. Picking between them is simpler than the arguments suggest, because the thing that decides your throughput is not the library.
requests: synchronous, by far the most widely used, feature-complete and stable.httpx: synchronous and asynchronous in one API, with HTTP/2 support.aiohttp: asynchronous only, and also an HTTP server framework.
The benchmark
We ran 50 GET requests against a local test server that sleeps 50 ms before answering, so the numbers reflect waiting on a server rather than parsing. Running locally removes network variance, which is the point: we want to compare the clients, not our internet connection.
N = 50
DELAY = 0.05 # each response waits 50 ms, like a real server
def requests_seq():
with requests.Session() as s:
for _ in range(N): s.get(URL)
return N
async def _aiohttp_async():
async with aiohttp.ClientSession() as s:
async def one():
async with s.get(URL) as r: await r.read()
await asyncio.gather(*(one() for _ in range(N)))
return NThree runs on the same machine, Python 3.10, requests 2.34.2, httpx 0.28.1, aiohttp 3.14.5:
run 1 run 2 run 3
requests, sequential 17.8/s 16.9/s 17.0/s
httpx, sequential 17.0/s 14.3/s 16.9/s
httpx.AsyncClient, concurrent 133.8/s 195.7/s 245.0/s
aiohttp, concurrent 664.7/s 402.7/s 307.7/sTwo things come out of this, and only one of them is the one people argue about.
The first is the real finding. Sequential is about 17 requests per second and concurrent is between 8 and 40 times faster. The server sleeps 50 ms, so 50 sequential requests cannot take less than 2.5 seconds no matter which library sends them. All three sequential numbers are within noise of that floor. Your client choice changes almost nothing; your concurrency model changes everything.
The second is a caution. aiohttp looks faster than httpx here, but look at the spread: aiohttp ranged from 308 to 665 requests per second across three identical runs, and httpx from 134 to 245. The run-to-run variation is larger than the gap in two of the three runs. At 50 requests the whole async test finishes in under half a second, so startup cost and scheduler jitter dominate. We are not going to tell you aiohttp is twice as fast, because our own measurements do not support that claim. If you need a real answer for your workload, benchmark your workload.
So which should you use
Use requests when the work is sequential, a script, or a small number of calls. It is the most documented library in Python and the one every answer online assumes. There is no performance reason to leave it for sequential work.
Use httpx when you want one API for both styles, or when you need HTTP/2. Its synchronous API is close enough to requests that porting is mostly mechanical, and httpx.AsyncClient is available in the same library when a part of your code needs concurrency.
Use aiohttp when the whole application is already async, or when you want the server and client from one package. It is the most established of the three in async-first codebases.
Do not move to an async client in the hope of a speedup if your code still awaits one request at a time. An async client used sequentially is a synchronous client with extra syntax, and our sequential numbers are the proof.
Proxy support, which is where they differ most
All three support proxies, with different spellings. This matters if you are rotating addresses, because the shape of the API decides how awkward the rotation is.
requests takes a dict per request or per session:
import requests
proxies = {"http": "http://user:pass@203.0.113.10:8080",
"https": "http://user:pass@203.0.113.10:8080"}
r = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10)httpx takes a single proxy argument on the client:
import httpx
with httpx.Client(proxy="http://user:pass@203.0.113.10:8080") as c:
r = c.get("https://httpbin.org/ip")aiohttp takes it per request, and reads credentials separately:
import aiohttp
async with aiohttp.ClientSession() as s:
async with s.get("https://httpbin.org/ip",
proxy="http://203.0.113.10:8080",
proxy_auth=aiohttp.BasicAuth("user", "pass")) as r:
print(await r.json())One practical difference: httpx sets the proxy on the client, so a pool of clients is the natural way to hold a pool of addresses. requests and aiohttp take it per request, which makes it easier to pick a different address for every call from one session. Neither is better; they push you toward different rotation code.
A second difference that costs people time: aiohttp does not read the HTTP_PROXY and HTTPS_PROXY environment variables unless you pass trust_env=True. requests and httpx read them by default. A script that works under requests and ignores your proxy under aiohttp is usually hitting exactly this.
For the full set of languages, how to use a proxy in every major programming language covers the same ground outside Python, and python requests for scraping goes deeper on sessions, headers and retries.
Porting between them
Moving from requests to httpx is mostly mechanical, which is the main practical argument for httpx over aiohttp if you are migrating existing code.
requests.get(...)becomeshttpx.get(...), with the sameparams,headers,jsonandtimeoutarguments.requests.Session()becomeshttpx.Client(), and both work as context managers.r.json(),r.text,r.status_codeandr.headersare identical.r.raise_for_status()exists in both.
Three differences will catch you. httpx has a default timeout and requests does not, so code that silently relied on waiting forever now raises. Redirects are not followed by default in httpx, where requests follows them, so add follow_redirects=True when you need the old behaviour. And the proxy argument is spelled differently, as shown above.
Moving to aiohttp is not mechanical. Every call site becomes async, which propagates up through your code until something runs an event loop. That is a reasonable change to make deliberately and a poor one to make casually.
Things that are easy to get wrong
Reuse the session or client. Creating a new requests.Session or httpx.Client per request throws away connection pooling and TLS handshakes, and that cost is real even when the library is not the bottleneck.
Always set a timeout. requests has no default timeout, so a hung server hangs your script forever. httpx defaults to 5 seconds and aiohttp to 5 minutes. Set it explicitly in all three and you never have to remember which is which.
Limit concurrency deliberately. asyncio.gather over 10,000 URLs will try to open 10,000 connections. Use a semaphore, or aiohttp's connector limit, and remember that the polite ceiling for someone else's server is far below what your machine can manage. Rate limiting for scrapers covers choosing that number.
Check HTTP/2 is doing what you think. httpx only enables it when you install the extra and pass http2=True. Against a server that does not offer HTTP/2, you get HTTP/1.1 and no error.
Try it yourself
Create an account, add funds from US$1 and order a proxy in the country you need.
Keep reading
25 Nov 2026 · Tutorials
How to find your proxy server address and port
Find the proxy your machine is already configured to use on Windows, macOS, Linux and in browsers, or find the host and port of a proxy you bought.
16 Nov 2026 · Tutorials
XPath and CSS selector cheat sheet for web scraping
XPath and CSS selectors side by side, from classes and attributes to contains-text, position, parents and siblings, each one tested on the same HTML with its real output.