Nginx keepalive的默认值 [英] Default value of nginx keepalive

查看:657
本文介绍了Nginx keepalive的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在nginx.org中,keepalive配置的默认值为-,但是我不太明白这是什么意思.

From nginx.org, the default value of keepalive config is —, however I don't quite understand what does this mean.

Syntax: keepalive connections;
Default:    —
Context:    upstream
This directive appeared in version 1.1.4.

推荐答案

为了使Nginx保持TCP连接保持活动状态,应将上游部分和原始服务器都配置为不最终确定连接.上游部分keepalive的默认值表示不执行keepalive,因此每次看到原始服务器的每个请求的TCP流数量增加时,都不会重用连接,这与keepalive的情况相反.您可以使用tcpdump进行检查.

In order Nginx to keep TCP connection alive both upstream section and origin server should be configured to not finalise the connection. Upstream section keepalive default value means no keepalive, hence connection won't be reused, each time you can see TCP stream number increases per every request to origin server, opposite to what happens with keepalive. You can check it with using tcpdump.

10倍应用程序性能的10个技巧博客帖子对它的描述非常好:

10 Tips for 10x Application Performance blog post describes it very well:

客户端保持连接–保持连接减少了开销,尤其是 使用SSL/TLS时.对于NGINX,您可以增加最大数量 客户端可以通过给定连接进行的keepalive_requests数量 默认值100,您可以将keepalive_timeout增加到 使keepalive连接保持打开状态的时间更长,从而导致 后续请求更快.

Client keepalives – Keepalive connections reduce overhead, especially when SSL/TLS is in use. For NGINX, you can increase the maximum number of keepalive_requests a client can make over a given connection from the default of 100, and you can increase the keepalive_timeout to allow the keepalive connection to stay open longer, resulting in faster subsequent requests.

上游Keepalive –上游连接–与 应用程序服务器,数据库服务器等–从中受益 保持活动连接.对于上游连接,您可以 增加keepalive,空闲的keepalive连接数 对每个工作进程保持开放.这允许增加 连接重用,减少了打开全新的需求 连接.有关更多信息,请参阅我们的博客文章HTTP 保持连接和Web性能.

Upstream keepalives – Upstream connections – connections to application servers, database servers, and so on – benefit from keepalive connections as well. For upstream connections, you can increase keepalive, the number of idle keepalive connections that remain open for each worker process. This allows for increased connection reuse, cutting down on the need to open brand new connections. For more information, refer to our blog post, HTTP Keepalive Connections and Web Performance.

另请参见 RFC-793 第3.5节:

TCP连接可能以两种方式终止:(1)正常的TCP关闭 使用FIN握手的顺序,以及(2)中止",其中一个或 发送了更多的RST段,并且连接状态立即变为 丢弃.如果TCP连接被远程站点关闭,则本地 必须通知应用程序是正常关闭还是关闭 流产了.

A TCP connection may terminate in two ways: (1) the normal TCP close sequence using a FIN handshake, and (2) an "abort" in which one or more RST segments are sent and the connection state is immediately discarded. If a TCP connection is closed by the remote site, the local application MUST be informed whether it closed normally or was aborted.

两个示例,请看下面的应用程序数据".

Two examples, take a look on Application Data below.

没有keepalive:

Without keepalive:

使用keepalive:

With keepalive:

这篇关于Nginx keepalive的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆