应该从Nginxconfiguration中删除`keepalive_timeout`吗?

哪一个更好的configuration/优化:明确限制keepalive_timeout或允许Nginx自行终止keepalive连接?

我看到了两个相互矛盾的build议,关于Nginx的keepalive_timeout指令。 他们如下:

 # How long to allow each connection to stay idle; longer values are better # for each individual client, particularly for SSL, but means that worker # connections are tied up longer. (Default: 65) keepalive_timeout 20; 

 # You should remove keepalive_timeout from your formula. # Nginx closes keepalive connections when the # worker_connections limit is reached. 

keepalive_timeout的Nginx 文档没有提及自动查杀,而且我只看到过这个build议,但是它让我感到很兴奋。

该服务器仅提供TLS安全连接,所有未encryption的连接立即重新路由到相同URL的https://版本。

当达到worker_connections限制时,Nginxclosureskeepalive连接。

确实如此。

  • src / core / ngx_connection.c:l843 – ngx_drain_connections();
  • src / http / ngx_http_request.c:l3042 – ngx_reusable_connection(c, 1);