[Linux 调优] 长连接(KeepAlive)在 http 连接中的性能影响
转载本站文章请注明,转载自:扶凯[http://www.php-oa.com]
本文链接: http://www.php-oa.com/2010/06/30/keepalive-http1-1.html
一直很想知道,在 http 1.1 中的长连接功能,如果在理想的环境中,对性能的影响.所以简单的做了一下测试
未使用长连接
Concurrency Level: 200 Time taken for tests: 7.016 seconds Complete requests: 30000 Failed requests: 0 Write errors: 0 Total transferred: 134524481 bytes HTML transferred: 122884096 bytes Requests per second: 4275.85 [#/sec] (mean) Time per request: 46.774 [ms] (mean) Time per request: 0.234 [ms] (mean, across all concurrent requests) Transfer rate: 18724.15 [Kbytes/sec] received
使用长连接
Concurrency Level: 200 Time taken for tests: 5.006 seconds Complete requests: 30000 Failed requests: 0 Write errors: 0 Keep-Alive requests: 30000 Total transferred: 135338747 bytes HTML transferred: 123486848 bytes Requests per second: 5992.49 [#/sec] (mean) Time per request: 33.375 [ms] (mean) Time per request: 0.167 [ms] (mean, across all concurrent requests) Transfer rate: 26400.24 [Kbytes/sec] received
由上面可以看出,在理想的环境中,如果打开长连接,可以处理6k/s 的响应,如果关掉长连接,只能处理4.2k/s 的响应.我想实际的环境影响一定小很多..但一定程度的说明长连接还是相当有用的.
换 2.7 的 squid 测试
Requests per second: 6004.86 [#/sec] (mean) Requests per second: 8680.81 [#/sec] (mean)
这个更新明显,有 3k 的差别了…



















被测模型是啥样的?纯静态多图片?
嗯,静态进行公平的性能测试,主要对比 效率