长连接KeepAlive
httpd的持久链接主要依靠KeepAlive
有以下几个相关的指令‘
- KeepAlive On|Off #是否开启KeepAlive长连接
- KeepAliveTimeout 15 #长连接多久算是超时,超时之后自动断开长连接
- MaxKeepAliveRequests 100 #长连接最多接受多少个请求。请求数量大于改值则自动断开。
在主配置文件/usr/local/httpd/conf/httpd.conf添加
KeepAlive On|Off
KeepAliveTimeout 15
MaxKeepAliveRequests 100
检查一下配置文件并重启
httpd -t
httpd -k restart
用telnet模拟请求 测试一下是否超时会断开
yum install telnet -y
[root@www ~]# telnet 192.168.253.128 80 ##访问的服务器IP 端口
Trying 192.168.253.128...
Connected to 192.168.253.128.
Escape character is '^]'.
GET /index.html HTTP/1.1 ##格式 请求方法 URL http协议版本
Host:192.168.253.128 ##服务端IP
HTTP/1.1 200 OK
Date: Thu, 26 Jul 2018 15:03:22 GMT
Server: Apache/2.4.34 (Unix)
Last-Modified: Thu, 26 Jul 2018 11:08:09 GMT
ETag: "c-571e502aa9cbd"
Accept-Ranges: bytes
Content-Length: 12
Content-Type: text/html
www.ice.com
Connection closed by foreign host.