配置Apache的KeepAlive参数

-- TOC --

Apache服务器关于KeepAlive的配置参数在/extra/httpd-default.conf这个文件中,涉及到3个参数:

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5

KeepAlive On,表示打开这个功能;

KeepAliveTimeout 5,表示HTTP底层的TCP连接成功之后,如果没有HTTP请求到来,超时时间是5秒;

KeepAliveTimeout的单位,可以使毫秒,millisecond。如果配置毫秒,需要在数字后面加一个postfix,ms。比如:KeepAliveTimeout 2500ms

MaxKeepAliveRequests 100,表示在一个TCP连接中,最大支持的HTTP请求数量,100就是表示,HTTP的请求数量达到100后,TCP会强制中断。

要让此配置生效,需要先修改Apache的主配置文件httpd.conf:

Include conf/extra/httpd-default.conf

去掉这个配置文件前面的#,让其配置生效。最后重新Apache。

本文链接:https://cs.pynote.net/net/httpd/202204052/

-- EOF --

-- MORE --