为减少jmeter对机器性能的消耗,有以下注意事项:
- 不使用监听器
View Results in Table => OutOfMemory guarantee in GUI Mode
View Results in Tree => OutOfMemory guarantee in GUI Mode
Graph Results => Performance issues
Assertion Results => OutOfMemory guarantee
Comparison Assertion Visualizer
Distribution Graph (alpha) => Performance issues
Graph Results => Performance issues
保持使用最新版本
新版本JMeter的性能已经得到极大提高负载测试使用NON-GUI模式
JMeter has 2 modes:
- GUI mode is for creating the test plan, checking it, debuging it BUT NOT FOR MASSIVE LOAD TEST . AWT Event Thread will disrupt your Load Test.
- NON-GUI mode is for massive load testing, it is as simple as:
<JMETER_HOME>/bin/jmeter -t <Path to Test Plan> -n -l <path to results>/results.csv
配置合适的JMeter虚拟内存
保存输出结果使用CSV格式
在属性文件添加如下代码
jmeter.save.saveservice.output_format=csv
jmeter.save.saveservice.data_type=false
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
jmeter.save.saveservice.response_data.on_error=false
jmeter.save.saveservice.response_message=false
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.subresults=false
jmeter.save.saveservice.assertions=false
jmeter.save.saveservice.latency=true
jmeter.save.saveservice.bytes=true
jmeter.save.saveservice.hostname=true
jmeter.save.saveservice.thread_counts=true
jmeter.save.saveservice.sample_count=true
jmeter.save.saveservice.response_message=false
jmeter.save.saveservice.assertion_results_failure_message=false
jmeter.save.saveservice.timestamp_format=HH:mm:ss
jmeter.save.saveservice.default_delimiter=;
jmeter.save.saveservice.print_field_names=true
有效使用后置处理器和断言
有效使用正则表达式提取器
最好提取尽量少的数据尽量不使用XPath提取器
使用Response Assertion or Size assertion
这两个组件能满足99%的测试需求,避免使用耗资源的组件:
XML Assertion
XML Schema Assertion
XPath Assertion
使用JSR 223 + Groovy编写脚本
执行完测试后再生成报告
分布式(远程)测试
当使用一台机器达到极限,可以切换为分布式测试或远程测试若还不能满足
使用能支持JMeter4的云解决方案
来源:
JMeter Performance and Tuning Tips
http://www.ubik-ingenierie.com/blog/jmeter_performance_tuning_tips/