Add Python SDK option to opt out of HTTP/2#1406
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @sarmientoF on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
🦋 Changeset detectedLatest commit: ca635b4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
54abb22 to
f847e58
Compare
|
We require contributors to sign our Contributor License Agreement, and we don't have @sarmientoF on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
f847e58 to
ca635b4
Compare
|
switching to http1 leads to more problems than it solves |
|
To reopen, please submit a reproduction of the issue along with metrics for performance |
|
I revised the branch based on the feedback:
Key result from a real E2B sandbox workload: 180 concurrent This keeps default users on HTTP/2 and gives high fan-out users a documented escape hatch instead of requiring monkeypatching. |
|
Opened a fresh PR with the revised scope and current head SHA because this closed PR would not reopen or refresh its head ref: #1407 The new PR keeps HTTP/2 as default and includes the reproduction/metrics requested here. |
Summary
http2connection option so callers can opt out withhttp2=Falsefor API and envd transports.Why
For normal use, HTTP/2 remains the right default. The opt-out is for server-side high fan-out workloads where
httpxuses one HTTP/2 connection per origin and therefore one serverMAX_CONCURRENT_STREAMSbudget. Once a workload has more long-lived concurrent envd RPCs than the peer stream cap, HTTP/2 requests queue behind that single connection instead of spreading across the existing connection pool.http2=Falsegives those workloads a documented alternative: HTTP/1.1 uses the SDK/httpx connection pool and avoids coupling all concurrent envd RPCs to one HTTP/2 stream budget. This is useful for bash/filesystem/commands/pty/control-plane fan-out and does not change behavior for default users.Reproduction / metrics
Using this branch and
AsyncSandbox.commands.run, I ran 180 concurrent commands against one sandbox:Workload:
sleep 4; echo ok, 180 concurrent server-streaming envd RPCs.The HTTP/2 run completes in two waves because concurrency above the stream budget cannot use a second HTTP/2 connection. The HTTP/1.1 opt-out completes in one wave because requests are distributed through the connection pool.
Tests
./.venv/bin/pytest tests/test_api_client_transport.py tests/sync/sandbox_sync/test_config_propagation.py tests/async/sandbox_async/test_config_propagation.py./.venv/bin/ruff check ../.venv/bin/ruff format --check ../.venv/bin/ty check