-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken connections with many concurrent HEAD
requests
#427
Comments
With a more sophisticated testing approach that doesn't interleave import httpx
import anyio
from collections import defaultdict
ATTEMPTS = 2000
TARGET = "http://localhost:8000"
METHODS = ["HEAD", "GET", "POST"]
RESULTS = defaultdict(list)
async def query(client: httpx.AsyncClient, method: str, url: str):
try:
response = await getattr(client, method.lower())(url)
response.raise_for_status()
except Exception as exc:
RESULTS[method].append(exc)
print(".", end="")
async def main():
for method in METHODS:
async with httpx.AsyncClient(timeout=httpx.Timeout(timeout=300)) as client:
async with anyio.create_task_group() as tg:
for _ in range(ATTEMPTS):
tg.start_soon(query, client, method, TARGET)
anyio.run(main)
# Report
print()
for method in METHODS:
failures = RESULTS[method]
seen = set()
errors = []
for exc in failures:
if type(exc) in seen:
continue
seen.add(type(exc))
errors.append(exc)
print(f"{len(failures)}/{ATTEMPTS} {method} requests failed with {len(seen)} unique exception types")
for exc in errors:
print(f" - {type(exc).__name__} {exc}")
|
zanieb
changed the title
Broken connections with many concurrent requests
Broken connections with many concurrent Dec 21, 2023
HEAD
requests
This was referenced Dec 21, 2023
I've merged one of the two tickets related to this. The other one needs some smaller minor changes, working on those. |
Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using
waitress==2.1.2
andpyramid==2.0.2
I've discovered that ~1% of requests fail due to broken connections when there are many concurrent requests.Requests fail with a
BrokenResourceError
orReadError
orRemoteProtocolError: Server disconnected without sending a response.
orConnection reset by peer
etc.The server looks like:
If I increase the threads, nothing changes. If I use another WSGI server like
gunicorn
, there are no failed requests.I'm testing concurrent request success rates with following script:
I'm testing on macOS with Python 3.11.4.
I discovered this while working with
devpi
, see devpi/devpi#1022.The text was updated successfully, but these errors were encountered: