Add Python SDK option to opt out of HTTP/2#1407
Open
sarmientoF wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: 11b2f2d 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 |
Member
|
I will defer to @matthewlouisbrockman, but I don't think we should allow this - it would re-introduce the connection issues we've been trying to avoid by introducing http2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. Benchmark script: https://gist.github.com/sarmientoF/0d7db8c8f9cdaa154ab915088a238967Workload:
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