Allow opening multiple HTTP/2 connections at a time#129486
Draft
MihaZupan wants to merge 1 commit into
Draft
Conversation
Member
Author
|
/azp run runtime-libraries-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates SocketsHttpHandler’s HTTP/2 connection injection logic to allow multiple HTTP/2 connection attempts to be started in parallel under load (when multiple connections are enabled), and adds functional tests to validate the new behavior.
Changes:
- Update HTTP/2 pool injection heuristics to compute and start multiple concurrent connection attempts based on queued request count and observed
SETTINGS_MAX_CONCURRENT_STREAMS. - Adjust HTTP/2 per-connection initial stream concurrency estimation until the peer’s SETTINGS frame is observed.
- Add/extend functional tests covering parallel connection attempts and the disabled-multiple-connections scenario.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs | Adds new HTTP/2 functional tests for parallel connection-attempt injection and for the disabled-multiple-connections case; tweaks server backlog for a low-concurrency memoization test. |
| src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs | Initializes _maxConcurrentStreams based on the pool’s last-seen value, falling back to InitialMaxConcurrentStreams until SETTINGS are received. |
| src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.Http2.cs | Reworks HTTP/2 connection injection to support starting multiple connection attempts in parallel and tracks a count of pending HTTP/2 connections. |
| src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.Http1.cs | Renames the max-connection limit field usage to a shared _maxHttpConnections identifier. |
| src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs | Changes _lastSeenHttp2MaxConcurrentStreams initialization (now starts as “unknown”). |
| connectionsToInject = (int)((_http2RequestQueue.Count + concurrency - 1) / concurrency); | ||
|
|
||
| // This step may be delayed until something else happened (e.g. a previous connection attempt completed / another request is queued), | ||
| // so there can be a slight delay until we start agressively opening many connections in case of an initial burst of requests on a new connection pool. |
Comment on lines
55
to
+56
| // Same as the above, but for SETTINGS_MAX_CONCURRENT_STREAMS. | ||
| internal uint _lastSeenHttp2MaxConcurrentStreams = Http2Connection.InitialMaxConcurrentStreams; | ||
| internal uint _lastSeenHttp2MaxConcurrentStreams; |
| return await DefaultConnectCallback(context.DnsEndPoint, ct).ConfigureAwait(false); | ||
| }; | ||
|
|
||
| HttpClient client = CreateHttpClient(handler); |
This was referenced Jun 17, 2026
Open
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.
Testing a possible implementation of #66944