From aafcc55006fcf6fa3185b86f7d19e259089c0be1 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 28 Feb 2016 00:06:40 +0900 Subject: [PATCH] nghttpx: Deprecate --http2-max-concurrent-streams option We added 2 new option instead: --frontend-http2-max-concurrent-streams and --backend-http2-max-concurrent-streams. --- gennghttpxfun.py | 4 +++- src/shrpx.cc | 32 +++++++++++++++++++++++++++----- src/shrpx_config.cc | 30 ++++++++++++++++++++++++++++-- src/shrpx_config.h | 7 ++++++- src/shrpx_http2_session.cc | 2 +- src/shrpx_http2_upstream.cc | 2 +- src/shrpx_spdy_upstream.cc | 2 +- 7 files changed, 67 insertions(+), 12 deletions(-) diff --git a/gennghttpxfun.py b/gennghttpxfun.py index 1d9dc846..8ff8cf83 100755 --- a/gennghttpxfun.py +++ b/gennghttpxfun.py @@ -122,7 +122,9 @@ OPTIONS = [ "tls-ticket-key-memcached-cert-file", "tls-ticket-key-memcached-private-key-file", "tls-ticket-key-memcached-address-family", - "backend-address-family" + "backend-address-family", + "frontend-http2-max-concurrent-streams", + "backend-http2-max-concurrent-streams" ] LOGVARS = [ diff --git a/src/shrpx.cc b/src/shrpx.cc index e0e38688..975f390c 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -1096,6 +1096,7 @@ void fill_default_config() { // HTTP/2 SPDY/3.1 has connection-level flow control. The default // window size for HTTP/2 is 64KiB - 1. SPDY/3's default is 64KiB upstreamconf.connection_window_bits = 16; + upstreamconf.max_concurrent_streams = 100; nghttp2_option_new(&upstreamconf.option); nghttp2_option_set_no_auto_window_update(upstreamconf.option, 1); @@ -1106,14 +1107,13 @@ void fill_default_config() { auto &downstreamconf = http2conf.downstream; downstreamconf.window_bits = 16; downstreamconf.connection_window_bits = 16; + downstreamconf.max_concurrent_streams = 100; nghttp2_option_new(&downstreamconf.option); nghttp2_option_set_no_auto_window_update(downstreamconf.option, 1); nghttp2_option_set_peer_max_concurrent_streams(downstreamconf.option, 100); } - http2conf.max_concurrent_streams = 100; - auto &loggingconf = mod_config()->logging; { auto &accessconf = loggingconf.access; @@ -1621,10 +1621,18 @@ SSL/TLS: the complete HTTP/2 cipher suites black list. HTTP/2 and SPDY: - -c, --http2-max-concurrent-streams= + -c, --frontend-http2-max-concurrent-streams= Set the maximum number of the concurrent streams in one - HTTP/2 and SPDY session. - Default: )" << get_config()->http2.max_concurrent_streams << R"( + frontend HTTP/2 and SPDY session. + Default: )" + << get_config()->http2.upstream.max_concurrent_streams << R"( + --backend-http2-max-concurrent-streams= + Set the maximum number of the concurrent streams in one + backend HTTP/2 session. This sets maximum number of + concurrent opened pushed streams. The maximum number of + concurrent requests are set by a remote server. + Default: )" + << get_config()->http2.downstream.max_concurrent_streams << R"( --frontend-http2-window-bits= Sets the per-stream initial window size of HTTP/2 SPDY frontend connection. For HTTP/2, the size is 2**-1. @@ -2451,6 +2459,10 @@ int main(int argc, char **argv) { {SHRPX_OPT_TLS_SESSION_CACHE_MEMCACHED_ADDRESS_FAMILY, required_argument, &flag, 115}, {SHRPX_OPT_BACKEND_ADDRESS_FAMILY, required_argument, &flag, 116}, + {SHRPX_OPT_FRONTEND_HTTP2_MAX_CONCURRENT_STREAMS, required_argument, + &flag, 117}, + {SHRPX_OPT_BACKEND_HTTP2_MAX_CONCURRENT_STREAMS, required_argument, + &flag, 118}, {nullptr, 0, nullptr, 0}}; int option_index = 0; @@ -2946,6 +2958,16 @@ int main(int argc, char **argv) { // --backend-address-family cmdcfgs.emplace_back(SHRPX_OPT_BACKEND_ADDRESS_FAMILY, optarg); break; + case 117: + // --frontend-http2-max-concurrent-streams + cmdcfgs.emplace_back(SHRPX_OPT_FRONTEND_HTTP2_MAX_CONCURRENT_STREAMS, + optarg); + break; + case 118: + // --backend-http2-max-concurrent-streams + cmdcfgs.emplace_back(SHRPX_OPT_BACKEND_HTTP2_MAX_CONCURRENT_STREAMS, + optarg); + break; default: break; } diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index 7cb19d9f..85c36e68 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -660,6 +660,7 @@ enum { SHRPX_OPTID_BACKEND_HTTP1_TLS, SHRPX_OPTID_BACKEND_HTTP2_CONNECTION_WINDOW_BITS, SHRPX_OPTID_BACKEND_HTTP2_CONNECTIONS_PER_WORKER, + SHRPX_OPTID_BACKEND_HTTP2_MAX_CONCURRENT_STREAMS, SHRPX_OPTID_BACKEND_HTTP2_WINDOW_BITS, SHRPX_OPTID_BACKEND_IPV4, SHRPX_OPTID_BACKEND_IPV6, @@ -692,6 +693,7 @@ enum { SHRPX_OPTID_FRONTEND_HTTP2_CONNECTION_WINDOW_BITS, SHRPX_OPTID_FRONTEND_HTTP2_DUMP_REQUEST_HEADER, SHRPX_OPTID_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER, + SHRPX_OPTID_FRONTEND_HTTP2_MAX_CONCURRENT_STREAMS, SHRPX_OPTID_FRONTEND_HTTP2_READ_TIMEOUT, SHRPX_OPTID_FRONTEND_HTTP2_WINDOW_BITS, SHRPX_OPTID_FRONTEND_NO_TLS, @@ -1398,6 +1400,9 @@ int option_lookup_token(const char *name, size_t namelen) { if (util::strieq_l("backend-http2-connection-window-bit", name, 35)) { return SHRPX_OPTID_BACKEND_HTTP2_CONNECTION_WINDOW_BITS; } + if (util::strieq_l("backend-http2-max-concurrent-stream", name, 35)) { + return SHRPX_OPTID_BACKEND_HTTP2_MAX_CONCURRENT_STREAMS; + } break; } break; @@ -1412,6 +1417,9 @@ int option_lookup_token(const char *name, size_t namelen) { if (util::strieq_l("frontend-http2-connection-window-bit", name, 36)) { return SHRPX_OPTID_FRONTEND_HTTP2_CONNECTION_WINDOW_BITS; } + if (util::strieq_l("frontend-http2-max-concurrent-stream", name, 36)) { + return SHRPX_OPTID_FRONTEND_HTTP2_MAX_CONCURRENT_STREAMS; + } break; } break; @@ -1559,8 +1567,20 @@ int parse_config(const char *opt, const char *optarg, #else // !NOTHREADS return parse_uint(&mod_config()->num_worker, opt, optarg); #endif // !NOTHREADS - case SHRPX_OPTID_HTTP2_MAX_CONCURRENT_STREAMS: - return parse_uint(&mod_config()->http2.max_concurrent_streams, opt, optarg); + case SHRPX_OPTID_HTTP2_MAX_CONCURRENT_STREAMS: { + LOG(WARN) << opt << ": deprecated. Use " + << SHRPX_OPT_FRONTEND_HTTP2_MAX_CONCURRENT_STREAMS << " and " + << SHRPX_OPT_BACKEND_HTTP2_MAX_CONCURRENT_STREAMS << " instead."; + size_t n; + if (parse_uint(&n, opt, optarg) != 0) { + return -1; + } + auto &http2conf = mod_config()->http2; + http2conf.upstream.max_concurrent_streams = n; + http2conf.downstream.max_concurrent_streams = n; + + return 0; + } case SHRPX_OPTID_LOG_LEVEL: if (Log::set_severity_level_by_name(optarg) == -1) { LOG(ERROR) << opt << ": Invalid severity level: " << optarg; @@ -2314,6 +2334,12 @@ int parse_config(const char *opt, const char *optarg, case SHRPX_OPTID_BACKEND_ADDRESS_FAMILY: return parse_address_family(&mod_config()->conn.downstream.family, opt, optarg); + case SHRPX_OPTID_FRONTEND_HTTP2_MAX_CONCURRENT_STREAMS: + return parse_uint(&mod_config()->http2.upstream.max_concurrent_streams, opt, + optarg); + case SHRPX_OPTID_BACKEND_HTTP2_MAX_CONCURRENT_STREAMS: + return parse_uint(&mod_config()->http2.downstream.max_concurrent_streams, + opt, optarg); case SHRPX_OPTID_CONF: LOG(WARN) << "conf: ignored"; diff --git a/src/shrpx_config.h b/src/shrpx_config.h index 69d807f4..039d2a9d 100644 --- a/src/shrpx_config.h +++ b/src/shrpx_config.h @@ -228,6 +228,10 @@ constexpr char SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_PRIVATE_KEY_FILE[] = constexpr char SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_ADDRESS_FAMILY[] = "tls-ticket-key-memcached-address-family"; constexpr char SHRPX_OPT_BACKEND_ADDRESS_FAMILY[] = "backend-address-family"; +constexpr char SHRPX_OPT_FRONTEND_HTTP2_MAX_CONCURRENT_STREAMS[] = + "frontend-http2-max-concurrent-streams"; +constexpr char SHRPX_OPT_BACKEND_HTTP2_MAX_CONCURRENT_STREAMS[] = + "backend-http2-max-concurrent-streams"; constexpr size_t SHRPX_OBFUSCATED_NODE_LENGTH = 8; @@ -479,18 +483,19 @@ struct Http2Config { nghttp2_session_callbacks *callbacks; size_t window_bits; size_t connection_window_bits; + size_t max_concurrent_streams; } upstream; struct { nghttp2_option *option; nghttp2_session_callbacks *callbacks; size_t window_bits; size_t connection_window_bits; + size_t max_concurrent_streams; } downstream; struct { ev_tstamp stream_read; ev_tstamp stream_write; } timeout; - size_t max_concurrent_streams; bool no_cookie_crumbling; bool no_server_push; }; diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index 79920fe8..b988d2e6 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -1453,7 +1453,7 @@ int Http2Session::connection_made() { std::array entry; size_t nentry = 2; entry[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; - entry[0].value = http2conf.max_concurrent_streams; + entry[0].value = http2conf.downstream.max_concurrent_streams; entry[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; entry[1].value = (1 << http2conf.downstream.window_bits) - 1; diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 0c8795dc..0803433c 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -846,7 +846,7 @@ Http2Upstream::Http2Upstream(ClientHandler *handler) // TODO Maybe call from outside? std::array entry; entry[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; - entry[0].value = http2conf.max_concurrent_streams; + entry[0].value = http2conf.upstream.max_concurrent_streams; entry[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; entry[1].value = (1 << http2conf.upstream.window_bits) - 1; diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index d9c22209..70d4096c 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -547,7 +547,7 @@ SpdyUpstream::SpdyUpstream(uint16_t version, ClientHandler *handler) // TODO Maybe call from outside? std::array entry; entry[0].settings_id = SPDYLAY_SETTINGS_MAX_CONCURRENT_STREAMS; - entry[0].value = http2conf.max_concurrent_streams; + entry[0].value = http2conf.upstream.max_concurrent_streams; entry[0].flags = SPDYLAY_ID_FLAG_SETTINGS_NONE; entry[1].settings_id = SPDYLAY_SETTINGS_INITIAL_WINDOW_SIZE;