From d2729193c72fd01621bd2a55d64135f86a8674a5 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 27 Aug 2021 21:11:03 +0900 Subject: [PATCH] nghttpx: Add --frontend-http3-max-concurrent-streams option --- gennghttpxfun.py | 1 + src/shrpx.cc | 13 +++++++++++++ src/shrpx_config.cc | 10 ++++++++++ src/shrpx_config.h | 4 ++++ src/shrpx_http3_upstream.cc | 3 ++- 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gennghttpxfun.py b/gennghttpxfun.py index be2c8390..c2156cb9 100755 --- a/gennghttpxfun.py +++ b/gennghttpxfun.py @@ -187,6 +187,7 @@ OPTIONS = [ "frontend-http3-connection-window-size", "frontend-http3-max-window-size", "frontend-http3-max-connection-window-size", + "frontend-http3-max-concurrent-streams", ] LOGVARS = [ diff --git a/src/shrpx.cc b/src/shrpx.cc index e2733a6c..79d8da73 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -1568,6 +1568,7 @@ void fill_default_config(Config *config) { { auto &upstreamconf = http3conf.upstream; + upstreamconf.max_concurrent_streams = 100; upstreamconf.window_size = 256_k; upstreamconf.connection_window_size = 1_m; upstreamconf.max_window_size = 6_m; @@ -2939,6 +2940,11 @@ QUIC: Default: )" << util::utos_unit(config->http3.upstream.max_connection_window_size) << R"( + --frontend-http3-max-concurrent-streams= + Set the maximum number of the concurrent streams in one + frontend HTTP/3 connection. + Default: )" + << config->http3.upstream.max_concurrent_streams << R"( )"; #endif // ENABLE_HTTP3 @@ -3658,6 +3664,8 @@ int main(int argc, char **argv) { &flag, 177}, {SHRPX_OPT_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE.c_str(), required_argument, &flag, 178}, + {SHRPX_OPT_FRONTEND_HTTP3_MAX_CONCURRENT_STREAMS.c_str(), + required_argument, &flag, 179}, {nullptr, 0, nullptr, 0}}; int option_index = 0; @@ -4509,6 +4517,11 @@ int main(int argc, char **argv) { SHRPX_OPT_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE, StringRef{optarg}); break; + case 179: + // --frontend-http3-max-concurrent-streams + cmdcfgs.emplace_back(SHRPX_OPT_FRONTEND_HTTP3_MAX_CONCURRENT_STREAMS, + StringRef{optarg}); + break; default: break; } diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index 3fb61021..fa24b8d0 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -2600,6 +2600,9 @@ int option_lookup_token(const char *name, size_t namelen) { if (util::strieq_l("frontend-http2-max-concurrent-stream", name, 36)) { return SHRPX_OPTID_FRONTEND_HTTP2_MAX_CONCURRENT_STREAMS; } + if (util::strieq_l("frontend-http3-max-concurrent-stream", name, 36)) { + return SHRPX_OPTID_FRONTEND_HTTP3_MAX_CONCURRENT_STREAMS; + } break; } break; @@ -3954,6 +3957,13 @@ int parse_config(Config *config, int optid, const StringRef &opt, #endif // ENABLE_HTTP3 return 0; + case SHRPX_OPTID_FRONTEND_HTTP3_MAX_CONCURRENT_STREAMS: +#ifdef ENABLE_HTTP3 + return parse_uint(&config->http3.upstream.max_concurrent_streams, opt, + optarg); +#else // !ENABLE_HTTP3 + return 0; +#endif // !ENABLE_HTTP3 case SHRPX_OPTID_CONF: LOG(WARN) << "conf: ignored"; diff --git a/src/shrpx_config.h b/src/shrpx_config.h index 08b903f8..6dc61592 100644 --- a/src/shrpx_config.h +++ b/src/shrpx_config.h @@ -381,6 +381,8 @@ constexpr auto SHRPX_OPT_FRONTEND_HTTP3_MAX_WINDOW_SIZE = StringRef::from_lit("frontend-http3-max-window-size"); constexpr auto SHRPX_OPT_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE = StringRef::from_lit("frontend-http3-max-connection-window-size"); +constexpr auto SHRPX_OPT_FRONTEND_HTTP3_MAX_CONCURRENT_STREAMS = + StringRef::from_lit("frontend-http3-max-concurrent-streams"); constexpr size_t SHRPX_OBFUSCATED_NODE_LENGTH = 8; @@ -753,6 +755,7 @@ struct QUICConfig { struct Http3Config { struct { + size_t max_concurrent_streams; int32_t window_size; int32_t connection_window_size; int32_t max_window_size; @@ -1188,6 +1191,7 @@ enum { SHRPX_OPTID_FRONTEND_HTTP2_WINDOW_BITS, SHRPX_OPTID_FRONTEND_HTTP2_WINDOW_SIZE, SHRPX_OPTID_FRONTEND_HTTP3_CONNECTION_WINDOW_SIZE, + SHRPX_OPTID_FRONTEND_HTTP3_MAX_CONCURRENT_STREAMS, SHRPX_OPTID_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE, SHRPX_OPTID_FRONTEND_HTTP3_MAX_WINDOW_SIZE, SHRPX_OPTID_FRONTEND_HTTP3_READ_TIMEOUT, diff --git a/src/shrpx_http3_upstream.cc b/src/shrpx_http3_upstream.cc index d5c649cd..60d979ff 100644 --- a/src/shrpx_http3_upstream.cc +++ b/src/shrpx_http3_upstream.cc @@ -513,7 +513,8 @@ int Http3Upstream::init(const UpstreamAddr *faddr, const Address &remote_addr, ngtcp2_transport_params params; ngtcp2_transport_params_default(¶ms); - params.initial_max_streams_bidi = 100; + params.initial_max_streams_bidi = http3conf.upstream.max_concurrent_streams; + // The minimum number of unidirectional streams required for HTTP/3. params.initial_max_streams_uni = 3; params.initial_max_data = http3conf.upstream.connection_window_size; params.initial_max_stream_data_bidi_remote = http3conf.upstream.window_size;