jmeter 压测的时候,开太多连接,会有端口不够用的情况;可以通过使用长连接来解决:
有两个显而易见的配置:
1, keepALive 打勾,
2,client 选择 httpclient
这里client 也可以选择java
对于 keepalive + java 和 keepalive + httpclient 两个组合;
java 选项是有效的,httpclient 无效;
可以参考这篇文章的讲解: http://fuyunii.com/202220.html
要想使用keepalive 生效: 需要设置下面两个参数:
httpclient4.idletimeout=2147483647
Check connections if the elapsed time (Milliseconds) since the last
use of the connection exceed this value
httpclient4.validate_after_inactivity=1700
TTL (in Milliseconds) represents an absolute value.
No matter what, the connection will not be re-used beyond its TTL.
httpclient4.time_to_live=2147483647
但是一定要注意,我测试发现,这两个参数只有在一个 iteraction 里面有效:
如果你的线程组 是无限执行,依旧会有耗光端口;
这个配置下,一个线程不断重复,连接会不断的新建, 因为有另外一个参数控制了,每一轮迭代都会reset connection:
Reset HTTP State when starting a new Thread Group iteration which means:
true means next iteration is associated to a new user
false means next iteration is associated to same user
true involves:
- Closing opened connection
- resetting SSL State
httpclient.reset_state_on_thread_group_iteration=false
如果想复用connection; 就需要 设置为false;否则一轮迭代之后,又会新建很多连接;