From:http://sdh5724.javaeye.com/blog/645067
以下测试的机器, 我们已经优化OS几乎所有的网络参数。
先测试个200个并发的, 无论是否KeepAlive, 网卡被吃完了, 差不多960m, 差异非常小。KeepAlive以超级微弱优势获胜。很明显, 我们看到,KeepAlive的测试中, 由于不需要TCP握手的数据包,大约少了40m的流量。 也就是说, 握手的数据包大约有4.2%. 看来, 还是很不少的。
ab -k -c 200 -n 10000000
http://aaaa:8080/96/14/75/99961475-1.jpg
#ifstat
eth0
KB/s in KB/s out
3218.02 120456.4
3215.00 120420.4
ab -c 200 -n 10000000 http://aaaa:8080/96/14/75/99961475-1.jpg
#ifstat
eth0
KB/s in KB/s out
8142.51 120002.5
8137.53 120013.4
#ifstat
eth0
KB/s in KB/s out
3218.02 120456.4
3215.00 120420.4
ab -c 200 -n 10000000 http://aaaa:8080/96/14/75/99961475-1.jpg
#ifstat
eth0
KB/s in KB/s out
8142.51 120002.5
8137.53 120013.4
==================================================
由于内部网络数据比较快, 我把并发降低到5个。 很明显, 我们看到, KeepAlive比较大的优势85:55的数据流量比例。
ab -k -c 5 -n 10000000 http://aaaa:8080/96/14/75/99961475-1.jpg
#ifstat
eth0
KB/s in KB/s out
85946.20 85931.28
85400.38 85409.11
ab -c 5 -n 10000000 http://aaaa:8080/96/14/75/99961475-1.jpg
#ifstat
eth0
KB/s in KB/s out
55456.53 55263.43
55133.53 54878.56
在我这样的
盲目 测试下, 貌似看来, 还是能提高不少性能的, 短连接带来的消耗还是有的。实际上, 从当时OS的情况来看,还有很多其他性能指标发生了变形。
不过, 从生产环境再来看这个参数的设置, 还是很纠结了, 还是需要实际情况来看的。 这是个很纠结的东西。 我无法回答说, 一定要开启, 或者要开启多长时间。
转载于:https://blog.51cto.com/tianya23/453429