http-keepalive
2017-03-03 00:00
134 查看
HTTP persistent connection, also called HTTP keep-alive, or HTTP connection reuse, is the idea of using the same TCP connection to send and receive multiple HTTP requests/responses, as opposed to opening a new connection for every single request/response pair – Wikipedia.
HTTP pipelining is a technique in which multiple HTTP requests are sent on a single TCP connection without waiting for the corresponding responses.[1] -Wikipedia
简单说就是连接复用,客户端和web服务器都要支持才行.下面用tomcat做个试验.
环境
1.使用ab测试
2.本地启动tomcat服务
3.wireshark查看tcp握手情况
预期目标:
多次请求只有一次tcp握手
tomcat 服务器参数配置
acceptCount="1" maxConnections="1" maxThreads="1" minSpareThreads="1" disableKeepAlivePercentage="100"
因为我们配置的工作线程已经backlog都是1那么disableKeepAlivePercentage这个参数必须给设置为100.具体参数说明及验证以后再写.
ab 测试 加上 -k参数,表明启用http keep-alive
结果
可以看到只有一次握手
对比试验
让服务器不支持 keepalive disableKeepAlivePercentage=0 (表明工作线程占比为超过0%关闭对keepalive支持). 或者去掉ab -k参数
结果:
每次请求都是一次完整的tcp握手/挥手过程
HTTP pipelining is a technique in which multiple HTTP requests are sent on a single TCP connection without waiting for the corresponding responses.[1] -Wikipedia
简单说就是连接复用,客户端和web服务器都要支持才行.下面用tomcat做个试验.
环境
1.使用ab测试
2.本地启动tomcat服务
3.wireshark查看tcp握手情况
预期目标:
多次请求只有一次tcp握手
tomcat 服务器参数配置
acceptCount="1" maxConnections="1" maxThreads="1" minSpareThreads="1" disableKeepAlivePercentage="100"
因为我们配置的工作线程已经backlog都是1那么disableKeepAlivePercentage这个参数必须给设置为100.具体参数说明及验证以后再写.
ab 测试 加上 -k参数,表明启用http keep-alive
结果
可以看到只有一次握手
对比试验
让服务器不支持 keepalive disableKeepAlivePercentage=0 (表明工作线程占比为超过0%关闭对keepalive支持). 或者去掉ab -k参数
结果:
每次请求都是一次完整的tcp握手/挥手过程
相关文章推荐
- Apache 针对 HTTP KeepAlive 功能配置
- wikipedia讲http keepalive选项作用的图
- 关于HttpWebRequest.KeepAlive
- Http 1.0/1.1 KeepAlive
- 关于HTTP协议中的KeepAlive属性
- HTTP的KeepAlive和TCP的KeepAlive区别
- HttpWebRequest关于KeepAlive
- HTTP中的keepalive(长连接)
- keepalive——http
- HTTP的KeepAlive是开启还是关闭?
- 2012-01-29 19:01 Http的KeepAlive最详细的说明文档
- TCP中的KeepAlive与HTTP中的Keep-Alive
- HTTP的KeepAlive是开启还是关闭?
- 关于HTTP协议中的KeepAlive属性
- http1.0 http1.1 keepalive
- nginx-upstream-keepalive;accept_mutex-proxy_http_version-1.1-proxy_set_header-connection
- 十.长连接超时设置(ngx_http_upstream_keepalive_module)
- Http的KeepAlive
- 【转】http的keep-alive和tcp的keepalive区别
- 计算机网络探究(三) TCP和HTTP的keepAlive