nghttpx: Add --frontend-http3-max-concurrent-streams option

This commit is contained in:
Tatsuhiro Tsujikawa 2021-08-27 21:11:03 +09:00
parent 87fb325357
commit d2729193c7
5 changed files with 30 additions and 1 deletions

View File

@ -187,6 +187,7 @@ OPTIONS = [
"frontend-http3-connection-window-size", "frontend-http3-connection-window-size",
"frontend-http3-max-window-size", "frontend-http3-max-window-size",
"frontend-http3-max-connection-window-size", "frontend-http3-max-connection-window-size",
"frontend-http3-max-concurrent-streams",
] ]
LOGVARS = [ LOGVARS = [

View File

@ -1568,6 +1568,7 @@ void fill_default_config(Config *config) {
{ {
auto &upstreamconf = http3conf.upstream; auto &upstreamconf = http3conf.upstream;
upstreamconf.max_concurrent_streams = 100;
upstreamconf.window_size = 256_k; upstreamconf.window_size = 256_k;
upstreamconf.connection_window_size = 1_m; upstreamconf.connection_window_size = 1_m;
upstreamconf.max_window_size = 6_m; upstreamconf.max_window_size = 6_m;
@ -2939,6 +2940,11 @@ QUIC:
Default: )" Default: )"
<< util::utos_unit(config->http3.upstream.max_connection_window_size) << util::utos_unit(config->http3.upstream.max_connection_window_size)
<< R"( << R"(
--frontend-http3-max-concurrent-streams=<N>
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 #endif // ENABLE_HTTP3
@ -3658,6 +3664,8 @@ int main(int argc, char **argv) {
&flag, 177}, &flag, 177},
{SHRPX_OPT_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE.c_str(), {SHRPX_OPT_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE.c_str(),
required_argument, &flag, 178}, required_argument, &flag, 178},
{SHRPX_OPT_FRONTEND_HTTP3_MAX_CONCURRENT_STREAMS.c_str(),
required_argument, &flag, 179},
{nullptr, 0, nullptr, 0}}; {nullptr, 0, nullptr, 0}};
int option_index = 0; int option_index = 0;
@ -4509,6 +4517,11 @@ int main(int argc, char **argv) {
SHRPX_OPT_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE, SHRPX_OPT_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE,
StringRef{optarg}); StringRef{optarg});
break; break;
case 179:
// --frontend-http3-max-concurrent-streams
cmdcfgs.emplace_back(SHRPX_OPT_FRONTEND_HTTP3_MAX_CONCURRENT_STREAMS,
StringRef{optarg});
break;
default: default:
break; break;
} }

View File

@ -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)) { if (util::strieq_l("frontend-http2-max-concurrent-stream", name, 36)) {
return SHRPX_OPTID_FRONTEND_HTTP2_MAX_CONCURRENT_STREAMS; 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;
} }
break; break;
@ -3954,6 +3957,13 @@ int parse_config(Config *config, int optid, const StringRef &opt,
#endif // ENABLE_HTTP3 #endif // ENABLE_HTTP3
return 0; 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: case SHRPX_OPTID_CONF:
LOG(WARN) << "conf: ignored"; LOG(WARN) << "conf: ignored";

View File

@ -381,6 +381,8 @@ constexpr auto SHRPX_OPT_FRONTEND_HTTP3_MAX_WINDOW_SIZE =
StringRef::from_lit("frontend-http3-max-window-size"); StringRef::from_lit("frontend-http3-max-window-size");
constexpr auto SHRPX_OPT_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE = constexpr auto SHRPX_OPT_FRONTEND_HTTP3_MAX_CONNECTION_WINDOW_SIZE =
StringRef::from_lit("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; constexpr size_t SHRPX_OBFUSCATED_NODE_LENGTH = 8;
@ -753,6 +755,7 @@ struct QUICConfig {
struct Http3Config { struct Http3Config {
struct { struct {
size_t max_concurrent_streams;
int32_t window_size; int32_t window_size;
int32_t connection_window_size; int32_t connection_window_size;
int32_t max_window_size; int32_t max_window_size;
@ -1188,6 +1191,7 @@ enum {
SHRPX_OPTID_FRONTEND_HTTP2_WINDOW_BITS, SHRPX_OPTID_FRONTEND_HTTP2_WINDOW_BITS,
SHRPX_OPTID_FRONTEND_HTTP2_WINDOW_SIZE, SHRPX_OPTID_FRONTEND_HTTP2_WINDOW_SIZE,
SHRPX_OPTID_FRONTEND_HTTP3_CONNECTION_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_CONNECTION_WINDOW_SIZE,
SHRPX_OPTID_FRONTEND_HTTP3_MAX_WINDOW_SIZE, SHRPX_OPTID_FRONTEND_HTTP3_MAX_WINDOW_SIZE,
SHRPX_OPTID_FRONTEND_HTTP3_READ_TIMEOUT, SHRPX_OPTID_FRONTEND_HTTP3_READ_TIMEOUT,

View File

@ -513,7 +513,8 @@ int Http3Upstream::init(const UpstreamAddr *faddr, const Address &remote_addr,
ngtcp2_transport_params params; ngtcp2_transport_params params;
ngtcp2_transport_params_default(&params); ngtcp2_transport_params_default(&params);
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_streams_uni = 3;
params.initial_max_data = http3conf.upstream.connection_window_size; params.initial_max_data = http3conf.upstream.connection_window_size;
params.initial_max_stream_data_bidi_remote = http3conf.upstream.window_size; params.initial_max_stream_data_bidi_remote = http3conf.upstream.window_size;