Skip to content

Commit 63276a7

Browse files
committed
http2: tune control flow defaults
The current defaults are unnecessarily conservative which makes http2 control flow over high latency connections (such as public internet) unbearably slow.
1 parent 6176222 commit 63276a7

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lib/internal/http2/core.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3288,12 +3288,16 @@ function connectionListener(socket) {
32883288

32893289
socket[kServer] = this;
32903290

3291+
// NGHTTP2 default is 64KB, but we want to allow more data to be
3292+
// buffered without applying backpressure.
3293+
session.setLocalWindowSize(512 * 1024);
3294+
32913295
this.emit('session', session);
32923296
}
32933297

32943298
function initializeOptions(options) {
32953299
assertIsObject(options, 'options');
3296-
options = { ...options };
3300+
options = { ...getDefaultSettings(), ...options };
32973301
assertIsObject(options.settings, 'options.settings');
32983302
options.settings = { ...options.settings };
32993303

lib/internal/http2/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ function getDefaultSettings() {
364364
settingsBuffer[IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL] === 1;
365365
}
366366

367+
// NGHTTP2 default is 64KB, but we want to allow more data to be
368+
// buffered without applying backpressure.
369+
holder.initialWindowSize = 256 * 1024;
370+
367371
if (settingsBuffer[IDX_SETTINGS_FLAGS + 1]) holder.customSettings = addCustomSettingsToObj();
368372

369373
return holder;

test/parallel/test-http2-binding.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const settings = http2.getDefaultSettings();
1717
assert.strictEqual(settings.headerTableSize, 4096);
1818
assert.strictEqual(settings.enablePush, true);
1919
assert.strictEqual(settings.maxConcurrentStreams, 4294967295);
20-
assert.strictEqual(settings.initialWindowSize, 65535);
20+
assert.strictEqual(settings.initialWindowSize, 256 * 1024);
2121
assert.strictEqual(settings.maxFrameSize, 16384);
2222

2323
assert.strictEqual(binding.nghttp2ErrorString(-517),

0 commit comments

Comments
 (0)