[Performance] Raise default HTTP/2 initial window size to 16 MiB#2213
Merged
Conversation
32b6b91 to
c1abfc6
Compare
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.
Motivation:
AHC defaulted the HTTP/2 initial window to 65535 (the RFC minimum), so any response larger than ~64 KiB stalls mid-transfer waiting for a WINDOW_UPDATE round-trip. The JDK HttpClient and OkHttp both default this per-stream window to 16 MiB, leaving AHC slower on HTTP/2 out of the box for no reason other than a conservative default.
Modification:
Raise the default http2InitialWindowSize to 16 MiB (16777216) in ahc-default.properties and the AsyncHttpClientConfig interface default, matching the JDK HttpClient and OkHttp. Still overridable via setHttp2InitialWindowSize.
Result:
liminates the per-response WINDOW_UPDATE stall on larger HTTP/2 bodies. In the 64 KiB-response benchmark this lifts HTTP/2 throughput about 64% (6.4k to 10.5k ops/s) and cuts median latency from 256 to 225 us, bringing AHC to parity with the JDK HttpClient and OkHttp. The value stays configurable, with tests covering both the new default and an override.