Hello, we're running a gRPC service behind an NGINX load balancer and we often see that the connection gets shut down with a GOAWAY message. Since our request deadlines are quite small and it takes some time to re-establish a connection this often leads to many failed requests.
After analyzing the situation we realized that it is caused by the "http2_max_requests" option which defaults to 1000. After setting this to a ridiculously high value our problems disappeared. While there probably are use cases where limiting the life time of a connection makes sense we were wondering why it is not possible to disable this functionality and let a connection just live as long as possible? The following patch allows to do just that by setting http2_max_requests to 0. Please let me know what you think. Thanks, Michael # HG changeset patch # User Michael Würtinger <michael.wuertin...@egym.com> # Date 1561569724 -7200 # Wed Jun 26 19:22:04 2019 +0200 # Node ID d703d79897320bfc743b2ea6421e301985b2c7e4 # Parent 35ea9229c71a9207a24e51f327e1749e3accb26c HTTP/2: allow unlimited number of requests in connection Allows to disable the "http2_max_requests" limit by setting it to 0. This enables very long living HTTP/2 connections which is desirable for some use cases like gRPC connections. diff -r 35ea9229c71a -r d703d7989732 src/http/v2/ngx_http_v2.c --- a/src/http/v2/ngx_http_v2.c Tue Jun 25 15:19:45 2019 +0300 +++ b/src/http/v2/ngx_http_v2.c Wed Jun 26 19:22:04 2019 +0200 @@ -1173,7 +1173,9 @@ ngx_http_v2_set_dependency(h2c, node, depend, excl); } - if (h2c->connection->requests >= h2scf->max_requests) { + if (h2scf->max_requests > 0 + && h2c->connection->requests >= h2scf->max_requests) + { h2c->goaway = 1; if (ngx_http_v2_send_goaway(h2c, NGX_HTTP_V2_NO_ERROR) == NGX_ERROR) { @@ -4514,7 +4516,7 @@ h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, ngx_http_v2_module); - if (h2c->idle++ > 10 * h2scf->max_requests) { + if (h2c->idle++ > 10 * h2scf->max_requests && h2scf->max_requests > 0) { ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, "http2 flood detected"); ngx_http_v2_finalize_connection(h2c, NGX_HTTP_V2_NO_ERROR); -- <https://egym.com> _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel