Title: Fix `bm_fastapi` benchmark failing with `httpx.PoolTimeout` under load by sendaoYan · Pull Request #509 · python/pyperformance · GitHub
Open Graph Title: Fix `bm_fastapi` benchmark failing with `httpx.PoolTimeout` under load by sendaoYan · Pull Request #509 · python/pyperformance
X Title: Fix `bm_fastapi` benchmark failing with `httpx.PoolTimeout` under load by sendaoYan · Pull Request #509 · python/pyperformance
Description: Fixes #508 Problem The fastapi benchmark (bm_fastapi) intermittently fails with httpx.PoolTimeout when the machine running the benchmark is under heavy load. The benchmark fires CONCURRENCY = 150 concurrent requests, but the httpx.AsyncClient uses httpx's default max_connections = 100. The 50 requests that exceed the pool size wait in the pool's queue for a connection to free up. httpx's default pool timeout is 5 seconds, so when the in-flight requests take longer than 5 seconds (which is exactly what happens under load), those 50 queued requests exceed the pool timeout and the benchmark dies: httpx.PoolTimeout RuntimeError: Benchmark died ERROR: Benchmark fastapi failed: Benchmark died Fix Size the connection pool to the benchmark's concurrency so that no request ever queues: - async with httpx.AsyncClient(trust_env=False) as client: + limits = httpx.Limits(max_connections=CONCURRENCY) + async with httpx.AsyncClient(limits=limits, trust_env=False) as client: With the pool sized to CONCURRENCY, all 150 requests acquire a connection immediately, so the pool timeout can never be hit regardless of server latency. This builds on the trust_env=False change from #505 and keeps it Testing Reproduced deterministically by serving the endpoint with an artificial ~6s per-request delay and firing 150 concurrent requests: Before: default pool (100 connections) → httpx.PoolTimeout after ~5.1s After: max_connections=150 → completes successfully (~7.1s) No behavior change in the common case: the benchmark's concurrency is a fixed constant, so the pool is simply sized to match it.
Open Graph Description: Fixes #508 Problem The fastapi benchmark (bm_fastapi) intermittently fails with httpx.PoolTimeout when the machine running the benchmark is under heavy load. The benchmark fires CONCURRENCY = 150 c...
X Description: Fixes #508 Problem The fastapi benchmark (bm_fastapi) intermittently fails with httpx.PoolTimeout when the machine running the benchmark is under heavy load. The benchmark fires CONCURRENCY = 150 c...
Opengraph URL: https://github.com/python/pyperformance/pull/509
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:ce354fe9-38d6-fb90-b8c4-7ca56369e4a1 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D0E8:10531B:29D4CF7:35855BC:6B01EC62 |
| html-safe-nonce | f86cfa87cd1ad0256ca064a94f58883da9b5b5a7041da8f8507b27e42f2d892d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEU4OjEwNTMxQjoyOUQ0Q0Y3OjM1ODU1QkM6NkIwMUVDNjIiLCJ2aXNpdG9yX2lkIjoiODUwNDUyMjQ5MDQ0MDE4Mjg4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | becd7147017ab5b767cc9760bc38109f5cba45ad2f544efe1e7bc8b8e399140d |
| hovercard-subject-tag | pull_request:5220149612 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/pyperformance/pull/509/files |
| twitter:image | https://avatars.githubusercontent.com/u/24123821?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/24123821?s=400&v=4 |
| og:image:alt | Fixes #508 Problem The fastapi benchmark (bm_fastapi) intermittently fails with httpx.PoolTimeout when the machine running the benchmark is under heavy load. The benchmark fires CONCURRENCY = 150 c... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/pyperformance git https://github.com/python/pyperformance.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 65949828 |
| octolytics-dimension-repository_nwo | python/pyperformance |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 65949828 |
| octolytics-dimension-repository_network_root_nwo | python/pyperformance |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width