Skip to content

[Performance] Raise default HTTP/2 initial window size to 16 MiB#2213

Merged
hyperxpro merged 1 commit into
mainfrom
h2-initial-window-default-16mib
Jun 28, 2026
Merged

[Performance] Raise default HTTP/2 initial window size to 16 MiB#2213
hyperxpro merged 1 commit into
mainfrom
h2-initial-window-default-16mib

Conversation

@hyperxpro

Copy link
Copy Markdown
Member

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.

@hyperxpro hyperxpro force-pushed the h2-initial-window-default-16mib branch from 32b6b91 to c1abfc6 Compare June 28, 2026 13:19
@hyperxpro hyperxpro merged commit 854f000 into main Jun 28, 2026
17 checks passed
@hyperxpro hyperxpro deleted the h2-initial-window-default-16mib branch June 28, 2026 19:08
@hyperxpro hyperxpro restored the h2-initial-window-default-16mib branch June 28, 2026 19:09
@hyperxpro hyperxpro deleted the h2-initial-window-default-16mib branch June 28, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant