From 0012f899dd3cbac828280529c7c6aa5dcb9fb870 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 4 Jun 2022 22:11:50 -0400 Subject: [PATCH] OPTIM: mux-h2: increase h2_settings_initial_window_size default to 64k This changes the default from RFC 7540's default 65535 (64k-1) to avoid avoid some degenerative WINDOW_UPDATE behaviors in the wild observed with clients using 65536 as their buffer size, and have to complete each block with a 1-byte frame, which with some servers tend to degenerate in 1-byte WU causing more 1-byte frames to be sent until the transfer almost only uses 1-byte frames. More details here: https://github.com/nghttp2/nghttp2/issues/1722 As mentioned in previous commit (MEDIUM: mux-h2: try to coalesce outgoing WINDOW_UPDATE frames) the issue could not be reproduced with haproxy but individual WU frames are sent so theoretically nothing prevents this from happening. As such it should be backported as a workaround for already deployed clients after watching for any possible side effect with rare clients. As an added benefit, uploads from curl now use less DATA frames (all are 16384 now). Note that the previous patch alone is sufficient to stop the issue with curl in case this one would need to be reverted. [wt: edited commit messaged, updated doc] --- doc/configuration.txt | 2 +- src/mux_h2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/configuration.txt b/doc/configuration.txt index 927c97ce39..183710c357 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -2744,7 +2744,7 @@ tune.h2.initial-window-size Sets the HTTP/2 initial window size, which is the number of bytes the client can upload before waiting for an acknowledgment from HAProxy. This setting only affects payload contents (i.e. the body of POST requests), not headers. - The default value is 65535, which roughly allows up to 5 Mbps of upload + The default value is 65536, which roughly allows up to 5 Mbps of upload bandwidth per client over a network showing a 100 ms ping time, or 500 Mbps over a 1-ms local network. It can make sense to increase this value to allow faster uploads, or to reduce it to increase fairness when dealing with many diff --git a/src/mux_h2.c b/src/mux_h2.c index 4b615fc894..cd3b5799c4 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -518,7 +518,7 @@ DECLARE_STATIC_POOL(pool_head_h2s, "h2s", sizeof(struct h2s)); /* a few settings from the global section */ static int h2_settings_header_table_size = 4096; /* initial value */ -static int h2_settings_initial_window_size = 65535; /* initial value */ +static int h2_settings_initial_window_size = 65536; /* initial value */ static unsigned int h2_settings_max_concurrent_streams = 100; static int h2_settings_max_frame_size = 0; /* unset */