1、网络带宽问题
对web进行压力测试时,通常百兆网络是不够的,当网络带宽不够的时候server端没有足够压力。用loadrunner所在的windows的性能管理器看一下网络利用率就知道了。
2、Vuser脚本的检查
Loadrunner提供了方便的脚本录制功能,但由于录制时可能出现的操作错误,vuser访问一些不存在的资源。去除某些与压力测试无关的东西。否则可能会出现Loadrunner测试结果有误或压力上不去的情况
3、Runtime setting
在创建Loadrunner scenario时,每台机器的vuser的runtime settings都应该分别设置并检查,不能只对第一个vuser的runtime settings进行设置。通常你会关掉think time,以便能用较少的机器达到较大的压力。另外,如果返回页面里包含了一些访问其他资源的链接比如图片服务器,这时应关掉 download non-html resources。
4、没有检查返回页面
当server端出错时应用程序有可能返回错误信息,但对HTTP来讲仍是成功的响应,返回码为200 OK. 这样在Loadrunner就被记为成功的transaction。于是,server端出错越多,Loadrunner测出的性能越好。解决办法:开启并检查应用的错误日志;或者启用Loadrunner的返回内容检查功能。
5、当心Loadrunner所在机器的磁盘空间
缺省情况下Loadrunner会把运行结果的详细信息放在C盘的Documment and Settings的用户目录下,当大压力长时间运行或有大量出错时,Loadrunner会生成大量的数据到该目录下。当磁盘空间满了后,机器的响应将变得很慢。
6、命令行打开LoadRunner
在多个场景需要运行的时候,可以通过批处理循环运行场景,保存结果到指定文件夹:
bat内容:
set LR_HOME=C:\Program Files\Mercury\LoadRunner
for /L %%iScenario in (1,1,10) do "%LR_HOME%\bin\Wlrun.exe" -Run -TestPath "%LR_HOME%\scenario\memory_leak_crash.lrs" -ResultName C:\LR_Result\result%%iScenario
由于lr的http 200的经典错误,所以需要加入验证点,如果加入了验证点,就使事务响应时间大于实际的响应时间,如何解决呢,利用lr_wasted_time解决,代码如下:
double time_elapsed, duration, waste;
merc_timer_handle_t timer;
lr_start_transaction("sampleTrans");
web_url("index.htm",
"URL=http://localhost/index.htm",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
timer = lr_start_timer();
// Do some checks the duration of which is not to be included in the transaction.
web_image_check("ImgCheck1",
"src=index_files/image002.jpg",
LAST);
web_image_check("ImgCheck2",
"src=index_files/planets.gif",
LAST);
// How long did the tests take in seconds.
time_elapsed = lr_end_timer(timer);
// Convert to millisecond.s
waste = time_elapsed * 1000;
// Remove the time the checks took from the transaction.
lr_wasted_time(waste);
lr_end_transaction("sampleTrans", LR_AUTO);