是否应从 Nginx 配置中删除 `keepalive_timeout`?

是否应从 Nginx 配置中删除 `keepalive_timeout`?

哪种配置/优化更好:明确限制keepalive_timeout还是允许 Nginx 自行终止保持连接?

我看到过两条关于keepalive_timeoutNginx 指令的相互矛盾的建议。它们如下:

# 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.

Nginx 文档因为keepalive_timeout没有提到自动杀戮,而且我只见过一次这样的建议,但它引起了我的兴趣。

该服务器提供TLS 安全连接和所有非加密连接都会立即重新路由到https://相同 URL 的版本。

答案1

当达到 worker_connections 限制时,Nginx 将关闭保持连接。

这是真的。

相关内容