Jmeter5.X踩坑合集(不定期更新)

Jmeter的最佳实践

使用最新版本的Jmeter

Jmeter近些年版本号刷的确实比以前快多了。根据官网的意思,Jmeter的性能已经有了大的提升,且修复不少bug,使用最新的准没错。

扩大内存使用

根据Jmeter官方文档的最佳实践,单个Jmeter压力机在现代电脑上可以支持到1000到2000个线程并发,更多可能就需要用到分布式压测。1000到2000并发默认1g的内存配置显然是不够的,为了避免因为内存不够导致的压测中莫名假死等各种未知的问题,可以配置Jmeter最大可使用的内存为压力机的一半。

NON-GUI运行模式用于生产环境,GUI模式用于调试环境

Using GUI mode as described here should only be used when debugging your Test Plan. To run the real load test, use NON-GUI mode.

也就是说在压测时,用命令行压测能得到更好的性能。

在压力或者性能测试下(生产环境)减少使用一些耗费资源的监听器,比如察看结果树,图形报告等,调试时可短暂启用用作调试作用

Graph Results MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.
View Results Tree MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.

官方给出的减少资源占用的建议

  • Use CLI mode: jmeter -n -t test.jmx -l test.jtl(使用命令行模式)
  • Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.(尽可能少用监听器)
  • Don’t use “View Results Tree” or “View Results in Table” listeners during the load test, use them only during scripting phase to debug your scripts.
  • Rather than using lots of similar samplers, use the same sampler in a loop, and use variables (CSV Data Set) to vary the sample. [The Include Controller does not help here, as it adds all the test elements in the file to the test plan.]
  • Don’t use functional mode
  • Use CSV output rather than XML
  • Only save the data that you need(只保存你需要的数据)
  • Use as few Assertions as possible(尽可能少用断言)
  • Use the most performing scripting language (see JSR223 section)(尽可能使用性能更好的groovy编写脚本)
  • If your test needs large amounts of data - particularly if it needs to be randomised - create the test data in a file that can be read with CSV Dataset. This avoids wasting resources at run-time.

配置

配置内存占用

Windows在jmeter.bat修改内存配置,重启后的bat显示当前的内存配置不会变,真正的内存参数要到jconsole或者VisualVM查看

if not defined HEAP (
    rem See the unix startup file for the rationale of the following parameters,
    rem including some tuning recommendations
    set HEAP=-Xms1g -Xmx12g -XX:MaxMetaspaceSize=1g
)

Linux在jmeter修改内存配置

# This is the base heap size -- you may increase or decrease it to fit your
# system's memory availability:
: "${HEAP:="-Xms1g -Xmx8g -XX:MaxMetaspaceSi
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值