Skip to content

http2: increase default window sizes#64623

Open
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:increase-http2-window-size
Open

http2: increase default window sizes#64623
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:increase-http2-window-size

Conversation

@mcollina

Copy link
Copy Markdown
Member

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes #38426

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/http2
  • @nodejs/net
  • @nodejs/sqlite

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jul 20, 2026
@mcollina
mcollina requested review from pimterry, ronag and trivikr and removed request for pimterry July 20, 2026 12:33
Comment thread src/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a pre-existing issue that this exposes: you can't configure this in advance. You can only control the connection window with session.setLocalWindowSize once you have a session, but at that point this initial WINDOW_UPDATE has already been sent, and shrinking the window isn't effective as shown in the tests here (it just blocks further updates, it can't reduce what's already been sent). The stream window is configurable in advance (it's a SETTINGS parameter) but this connection window isn't.

That already existed implicitly but it was kind of OK when the initial window was small, but it's a real problem with a very large initial window I think, since there's basically no way to override this to make it any smaller again if you need to.

Can we add client & server options for this, so it can be configured before the first WINDOW_UPDATE is sent somehow?

Comment thread src/node_http2.cc Outdated
// to window_size / RTT. With a 32MB connection window, throughput is
// significantly improved. See https://github.com/nodejs/node/issues/38426
CHECK_EQ(nghttp2_session_set_local_window_size(
session, NGHTTP2_FLAG_NONE, 0, 33554432), 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: would be nicer to extract this as a constant

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.14%. Comparing base (ace91de) to head (3825c24).
⚠️ Report is 50 commits behind head on main.

Files with missing lines Patch % Lines
src/node_http2.cc 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64623      +/-   ##
==========================================
- Coverage   90.23%   90.14%   -0.09%     
==========================================
  Files         741      741              
  Lines      241681   242086     +405     
  Branches    45547    45553       +6     
==========================================
+ Hits       218075   218227     +152     
- Misses      15141    15361     +220     
- Partials     8465     8498      +33     
Files with missing lines Coverage Δ
lib/internal/http2/core.js 94.87% <100.00%> (+0.06%) ⬆️
src/node_http2.h 92.26% <ø> (+0.21%) ⬆️
src/node_http2.cc 81.73% <0.00%> (-0.44%) ⬇️

... and 84 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina
mcollina force-pushed the increase-http2-window-size branch 2 times, most recently from 5c9bc03 to 4351b51 Compare July 20, 2026 16:48
@mcollina

Copy link
Copy Markdown
Member Author

Both addressed:

  1. Extracted DEFAULT_SETTINGS_LOCAL_CONNECTION_WINDOW_SIZE = 33554432 as a named constant in src/node_http2.h and used it in src/node_http2.cc.
  2. The pre-existing issue about not being able to configure the connection window in advance is noted — the initial WINDOW_UPDATE is sent at session creation before setLocalWindowSize can be called. This is a known limitation of the current API.

@mcollina
mcollina force-pushed the increase-http2-window-size branch from 4351b51 to 31761a0 Compare July 20, 2026 18:25

@RafaelGSS RafaelGSS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be semver-major PRs that contain breaking changes and should be released in the next major version. ?

@mcollina mcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 20, 2026
@mcollina

Copy link
Copy Markdown
Member Author

yes

Increase the default HTTP/2 stream window from 64KB (65535) to 4MB
(4194304) and the default local connection window to 32MB (33554432).

The default 64KB window limits throughput on high-latency connections
to window_size / RTT. With a 250ms RTT, throughput is limited to
256KB/s. The new defaults improve throughput to 16MB/s (128Mbps)
for the stream window and 128MB/s (1Gbps) for the connection window.

Fixes: nodejs#38426
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollina force-pushed the increase-http2-window-size branch from 31761a0 to 3825c24 Compare July 20, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase HTTP/2 window size by default

4 participants