admin管理员组文章数量:1534527
2024年1月25日发(作者:)
性能测试工具
LoadRunner
实验报告
一、概要介绍
1.1
软件性能介绍
1.1.1
软件性能的理解
性能是一种指标, 表明软件系统或构件对于其及时性要求的符合程度; 同时也是产品的 特性,可以用时间来进行度量。
表现为:对用户操作的响应时间;系统可扩展性;并发能力;持续稳定运行等。
1.1.2
软件性能的主要技术指标 响应时间:响应时间
=呈现时间
+系统响应时间 吞吐量:单位时间内系统处理的客户请求数量。 (请求数
/秒,页面数
/秒,访问人数
/
秒) 并发用户数:业务并发用户数;
[
注意
]
系统用户数: 系统的用户总数; 同时在线用户人数: 使用系统过程中同时在线人数达 到的最高峰值。
1.2 LoadRunner
介绍
LoadRunner
是
Mercury Interactive
来确认和查找问题。
的一款性能测试工具,也是目前应用最为广泛
的性能测试工具之一。 该工具通过模拟上千万用户实施并发负载, 实时性能监控的系统行为 和性能方式1.2.1 LoadRunner
工具组成
虚拟用户脚本生成器: 捕获最终用户业务流程和创建自动性能测试脚本, 即我们在以后说的 产生测试脚本;
压力产生器:通过运行虚拟用户产生实际的负载; 用户代理:协调不同负载机上虚拟用户,产生步调一致的虚拟用户; 压力调度:根据用户对场景的设置,设置不同脚本的虚拟用户数量; 监视系统:监控主要的性能计数器; 压力结果分析工具:本身不能代替分析人员,但是可以辅助测试结果的分析。
1.2.2 LoadRunner
工具原理
代理(
Proxy
)是客户端和服务器端之间的中介人,
LoadRunner
就是通过代理方式截获 客户端和服务器之间交互的数据流。
1)虚拟用户脚本生成器通过代理方式接收客户端发送的数据包,记录并将其转发给服 务器端;接收到从服务器端返回的数据流,记录并返回给客户端。
这样服务器端和客户端都以为在一个真实运行环境中, 虚拟脚本生成器能通过这种方式 截获数据流; 虚拟用户脚本生成器在截获数据流后对其进行了协议层上的处理, 最终用脚本 函数将数据流交互过程体现为我们容易看懂的脚本语句。
2)压力生成器则是根据脚本内容,产生实际的负载,扮演产生负载的角色。
3)用户代理是运行在负载机上的进程,该进程与产生负载压力的进程或是线程协作, 接受调度系统的命令,调度产生负载压力的进程或线程。
4)压力调度是根据用户的场景要求,设置各种不同脚本的虚拟用户数量,设置同步点
等。
5)监控系统则可以对数据库、应用服务器、服务器的主要性能计数器进行监控。
6)压力结果分析工具是辅助测试结果分析。
二、
LoadRunner
测试过程
2.1
计划测试 定义性能测试要求,例如并发用户的数量、典型业务流程和所需响应时间等。
2.2
创建
Vuser
脚本 将最终用户活动捕获(录制、编写)到脚本中, 并对脚本进行修改,调试等。
协议类型:取决于服务器端和客户端之间的通信协议; 脚本类型:
init
(初始部分)
,Action
(事务部分)
,end
(退出结束) ; 脚本录制:捕获应用程序所执行的操作; 验证回放:检查是否准确模拟了录制的会话; 事务:表示要度量的最终用户业务流程; 参数化:将录制的一些常来替换为参数;
内容检查:
LR
只检测到网页的响应,就认为是
pass
而不管当前网页的正确性,所以设置检 查点,确保在测试时结果的正确性;
迭代次数:
action
部分的循环次数。
2.3
创建场景
对
Vuser
脚本进行场景设置和负载环境设置。 场景类型
手动场景:通过定义
Vuser
组,
Vuser
脚本和运行脚本的负载生成器来创建场景; 百分比模式:定义场景中要使用的
Vuser
总数,负载生成器计算机以及要分配给每个
Vuser
脚本的
Vuser
占总数的百分比。
面向目标的场景;定义你希望的测试目标,
编辑计划:设置加压方式、压力持续时间和减压方式等。
场景组:选择组
/
脚本,虚拟用户数量以及负载生成器等。 运行时设置:对脚本进行运行时属性设置。
LR
会根据这些目标自动构建场景。
三、实验过程
1)安装完成进入
Loadrunner
主界面
lx
Mercury
UPDATE IKEN5E ABOUT $IWCRT | IB* EXFT
LoadRunner
Load Testing
■ 匚「e自te/Edit £匚r~ipts
」Run Load Tests
」 Analyze Load Tests
Accurate scripts form the foundation cf an effective load
test. Generally, load testing script h^s a one-to- one
relationship with a business process・ Thu匀
if you are load
terting a claims applicatiion,a script might include logging
in, opening a daim and logging outP Since Mercury
Interactive's LoadRunner® works an the record and
playback paradignij. you can open th已
Virtual User
Generator (VuGen)^ start recording
日nd walk through the
business process screen by screen- At the end of th^
recording sessiorij Load Runner® ge;ri erates a script
thatj, on plajrbackj ernijlates adding a daim exactly like 0
real user. Tin the real worldj thoughj hundreds of users log
in with different 10$ arid passwords aindl Enter unique data.
Thereforej the VuGen provides a complete environment to
extend Itiis template- Input deta can be data driven oir
pziranrwtEriwEd,session values can be correlated and
content checks can be inserted- In addition.^ transactions
can be ddded to measure and report on respanse times
under load-
More about Load Testing
(2)点击“
Create/Edit Scripts
”,启用后新建一个用户脚本,因为我们要测试 的是Web应用所以如下所示,选择
Web(HTTP/Html)协议
(3)点击
Vuser下的Start Recording,出现如下界面:
St art Recording
输入URL地址,开始录制脚本。
Vuser init
是录制脚本的起始点;
Actio n
是录制脚本的活动;
Suser end
是录制脚本的终止点;
的运行次数,确定后会出现如下界面:
(4)脚本录制完之,点击
Tools工具栏下的
Create Controller Seenario…选项,会出现脚本
此界面是规划脚本的开始数目,开始时间,驻留时间,退出时间,同时退出的数目等。
点击Edit scheduler按钮出现如下所示界面;
Schedule Builder
Schedule Nsme
Def dull Schedule
---------- Schedule Defiriicin
■* Schedule bp Scenario
Schedule Group
Ramp Vp | Duration Eimp Down
Load Sellings
'Load all Vusas sirmtafieously
(* Start )5 Vusers every |0000:15
~ Initialize alVunrs before Run.
(seledihg Ibis option means thal running begins only afler alVuser^ reach the Ready state]1. Ramp UP
上图所示为每15秒运行5个脚本;
2. Durati on
计划每个脚本的驻留时间;
3. Ramp Dow n
规定每隔多长时间退出多少数目; 点击OK,出现下图界面;
(5)开始压力负载测试:
图示数据只为说明,并不是实验真实数据
New.. I) Bename I Delete
Scenario
□K I Cane
日 也
b |
r
File
Mercury LoadRuiuier Controller - Scenario!
Mcnitprs Revolt's Ri^howtits
TQC|.S Htlp
1 - [Run]
□
0 I
MM
® ilb
衲菇rf
図
'
Design S Run
Aula Colltia
R«EU
四、实验结果:
Executive Summary
Objectives Add text here
Seen ario Summary
Total Durati on (in eludi ng Ramp Up/Dow n):
Maximum Running Vusers:
Total Throughput (bytes):
Total Hits:
Top Time-C on sumi ng Tran sact ions
Tran saction Name
vuser_i ni t_Tra nsactio n
vuser_e nd_Tra nsactio n
Action Tran sact ion
Con clusi ons
Add text here
Seen ario Con figurati on
Files
10 minu tes and 20 sec
onds.
50
Ave
0.189
0.013
0.001
90%
0.675
0.013
0
Name:
Results in Sessi on:
Sessi on Name:
Scheduler In formatio n
Started On:
En ded
On:
Duratio n:
Seen ariol
C:Docume nts and Sett in gsAdmi nistrator'Local
Sett in gsTempn on
Sessi on
30-11-2008 14:45:08
30-11-2008 14:55:29
Run for 000:05:00 (hhh:mm:ss)
Start 5 Vusers every 00:00:15 (hh:mm:ss) Load Behavior:
Scripts
Script Type File
C:Docume nts and Sett in gsAdmi nistrator'Local
Sett in gsTempno name3no
non ame3 QTWeb
Run Time Sett ings
QTWeb
Group
non ame3
Script
non ame3
Pacing
As soon
possible
Thi nk Time
as
As recorded
Network Speed
Maximum ban
dwidth
Browser cache
Yes
Users' Influence
Displays average transaction response times relative to the number of Vusers running at any given
point during the load test. This graph helps you view the general impact of Vuser load on performa
nee time and is most useful whe n an alyz ing a load test which is run with a gradual load.
Title:
Graph Type:
Base Graph:
Additio nal:
Gran ularity:
Tran sact ion Resp onse Time Un der Load
Correlate
Running Vusers
Average Tran sact ion Resp onse Time
1 Second
Transaction Re冏pm”。Time Uiidei Load
5
20 25 30 40
Number ofVusers
Color Scale Measureme nt
Action_Tran sact ion
vuser_e nd_Tra nsact
ion
vuser_i ni t_Tra nsacti
on
Min. Ave.
0.0
0.0
0.0
0.001
0.013
0.189
Max. SD
5.938
0.672
1.25
0.048
0.094
0.414
■
■
1
1
1
■
Vuser Load Scheme
Displays the number of Vusers that executed Vuser scripts, and their status, during each second of a
load test. This graph is useful for determining the Vuser load on your server at any given mome nt.
Running Vusers
Title:
Current Results:
Filters:
Group By:
Gran ularity:
16 Seconds
C:Docume nts and Sett in gsAdmi nistrator'Local Sett
in gsTempno
Vuser Status = (Run)
Riiimniig W牌却冷
00.0D 00-:30 01.00 01:30 0200 02:30 03.00 03.50 0^.00 04.-30 05:00 05.30 05:OG 06.30 07:00 07.30 03.30 09:30 10.00
Elapsed scanario lime mm:ss
Measurem
Color Scale
Graph
Graph Mi n.
0.0
Ave.
22.8
Graph
Max.
50
Graph
Media n
20
Graph
SD
16.742
ent
Run
■
1
Transaction Response Times
Displays the average time taken to perform transactions during each second of the load test. This
graph helps you determine whether the performance of the server is within acceptable minimum
and maximum transaction performance time ranges defined for your syste m.
Title:
Current Results:
Filters:
Group By:
Granularity: 16 Seconds
Average Transaction Response Time
C:Documents and SettingsAdministratorLocal Sett
ingsTempnoname3resres」rr
Transaction End Status = (Pass)
Aver^ig^ TMi^aciiah Response I ime
0 7S-
07
0.65-
0.B-
0.55
05
CL4G
0.4「
0.35
0.3-
0.25-
□ 2
0.15
0.1
0.05^
00.00 00:30 01.00 01.30 02:00 02.30 03:00 D3.3O D4.00 04:30 D5.30 06.00 06-30 07:00 07.30 00:30 09.00 09.30 10.00
Ehpsed sda-naria lime mm:ss
Color Scale Measureme nt
Action_Tran sact ion
vuser_e nd_Tra nsact
ion
vuser_i ni t_Tra nsacti
on
Mi n.
0.0
0.0
0.0
Ave.
0.001
0.013
0.189
Max.
5.938
0.672
1.25
SD
0.048
0.094
0.414
■
■
■
1
1
1
Running Vusers
Displays the number of Vusers that executed Vuser scripts, and their status, during each second of a load
test. This graph is useful for determining the Vuser load on your server at any given mome nt.
Running Vusers
Title:
Current Results:
Filters:
Group By:
Gran ularity:
16 Seconds
C:Docume nts and Sett in gsAdmi nistrator'Local Sett
in gsTempno
Vuser Status = (Run)
Rimnjmj Vusers
50
45-
4tf-
於-
30
25
20-
10-
a -
00.00 O0:3O 01.00 01:3D 0200 02:30 0300 03.30 04.30 05.00 05.30 OB:00 0630 07:DO 07.30 09.00 0&3O 09.00 0130 10 OD
Elapsed sc^nafia lime mm:8s
Measurem
Color Scale
Graph
Graph Mi n.
0.0
Ave.
22.8
Graph
Max.
50
Graph
Media n
20
Graph
SD
16.742
ent
Run
■
1
Tran sacti on Summary
Displays the nu mber of tran sact ions that passed, failed, stopped, or en ded with errors.
Title:
Current Results:
Filters:
Group By:
Tran sacti on Summary
C:Docume nts and Sett in gsAdmi nistrator'Local
Sett
in gsTempno
None
Average Transaction Response Time
Displays the average time taken to perform transactions during each second of the load test. This
graph helps you determine whether the performance of the server is within acceptable minimum
and maximum transaction performance time ranges defined for your syste m.
Title:
Current Results:
Filters:
Group By:
Granularity:
16 Seconds
Average Transaction Response Time
C:Documents and SettingsAdministratorLocal Sett
ingsTempnoname3resres
・lrr
Transaction End Status = (Pass)
Response 9 ime
0
7S^
07
0.65-
D.S-
0.55
05
0.45^
0.4 •
0.35
0.3-
0.25-
□ 2
0.15
0.1
0.05^
0
00.00 00:30 01.00 01:30 02.00 02.30 03:00 D3.30 D4.00 04:30 05.D0 05.30 OS.00 06-30 0?:00 07.30 0S.00 0B:30 09.00 09.30 10:00
Ehpsed scanaria lime mm:ss
Color Scale
Measureme Graph's
nt Min.
Action_Tra n
sact ion
vuser_e nd_
Tran sacti on
vuser_i nit_
Tran sacti on
Graph's
Ave.
Graph's
Max.
0.002
0.019
0.741
Graph's
Media n
0.002
0.0
0.027
Graph's
SD
0.001
0.008
0.282
■
■
1
1
1
0.0
0.0
0.0
0.001
0.004
0.181
■
Termino logy
LoadR unner Objects
Term Defin iti on
A Vuser script describes the actions that a Vuser performs during the seenario. Each
Vuser Scripts
Vuser executes a Vuser script during a scenario run. The Vuser scripts include
functions that measure and record the performanee of your application
抯
comp onen
ts.
Tests a system's ability to han dle a heavy workload. A load test simulates multiple
Load Test
transactions or users interacting with the computer at the same time and provides
reports on response times and system behavior.
Run-Time settings allow you to customize the way a Vuser script is executed. You con
Run- Time
Setti ngs
figure the run-time sett ings from the Con troller or VuGe n before running a seenario.
You can view information about the Vuser groups and scripts that were run in each
seenario, as well as the run-time settings for each script in a scenario, in the Seenario
Run-Time Settings dialog box.
A seenario defines the events that occur during each testing session. For example, a
Seen ario
seenario defines and controls the number of users to emulate, the actions that they
perform, and the mach ines on which they run their emulati ons.
The Schedule Builder allows you to set the time that the sce nario will start running,
Scheduler
the durati on time of the seen ario or of the Vuser groups with in the seen ario, and to
gradually run and stop the Vusers with in the seen ario or with in a Vuser group. It also
allows you to set the load behavior of Vusers in a sce nario.
When you work with the An alysis utility, you work with in a sessi on. An An alysis
session contains at least one set of seenario results (lrr file). The Analysis utility
Sessi on
processes the sce nario result in formati on and gen erates graphs and reports. The
An alysis stores the display in formati on and layout sett ings for the active graphs in a
file with an .Ira extension. Each session has a session name, result file name,
database n ame, directory path, and type.
A transaction represents an action or a set of actions used to measure the performa
Tran saeti ons
nee of the server. You defi ne tran sact ions with in your Vuser script by en clos ing the
appropriate sect ions of the script with start and end tran sact ion stateme nt.
Vusers or virtual users are used by LoadR unner as a replaceme nt for huma n users.
When you run a seen ario, Vusers emulate the acti ons of huma n users work ing with
Vusers
your application. A seenario can contain tens, hundreds, or even thousands of Vusers
running con curre ntly on a sin gle workstati on.
Graph In formatio n
Term
Defi niti on
Average
Hits
Maximum
Measureme nt
Media n
Minimum
Network Delay
Network Path
Resp onse time
Average value of the graph measureme nt's.
The nu mber of HTTP requests made by Vusers to the Web server.
Maximum value of the graph measureme nt's.
This is the type of resource being mon itored
Middle value of the graph measureme nt's.
Minimum value of the graph measureme nt's.
The time it takes for a packet of data sent across the network to go to the
requested node and retur n.
The Network Path is the route data travels betwee n the source mach ine and the
desti nati on mach ine.
The time take n to perform a tran sact ion.
In order to display all the measureme nts on a sin gle graph, thus making the
Scale
granu larity)
(or
graphs easier to read and an alyze, you can cha nge the scale or (gra nu larity) of
the x-axis. You can either set measurement scales manually, view measurement
trends for all measurements in the graph, or let Analysis scale them automatically.
The Lege nd tab in dicates the scale factor for each resource.
The square root of the arithmetic mean value of the squares of the deviations
from the arithmetic mean.
Throughput is measured in bytes and represents the amount of data that the
Vusers received from the server.
Whe n you run a seen ario, the Vusers gen erate load or stress on the server.
LoadRunner monitors the effect of this load on the performanee of your applicati
on.
Stan dard Deviati on
(SD)
Throughput
Vuser Load
五、实验小结
一、关联的格式和使用方法
web_reg_save_param( "WCSParam_Diff1",
"Ord=1",
elFrameld=1", LAST );
"LB=userSessio n value=", "RB=>",
"Search=Body","R
第一个参数: 表示把关联的内容都记录到这个变量里。可以把它当成一个变量。
第二个参数:左边的值
第三个参数:右边的值
第四个参数:ORD,当它的值是1的时候,表示在HTML脚卩本里只取第一个获取关联 的内容,如果在后面的文本里也有相同关联的内容则不给予处理, 当为ALL的时候,则
处理HTML脚本里所有的符合关联条件的数据,变量也自动生成
:
(
WCSParam_Diff1_count
)
count[n]={1,2,3,4,5,6,7,8,9 ...... }
最后
LAST
必不可少。后面两个参数可以根据帮助学习
web_reg_save_param("fcontent","LB=","RB=","SEARCH=BODY",LAST);//
空的关联获
取BODY里的内容下载文件用
二、字符串的格式和写法
strcpy(str, "RB=");
strcat(str, lr_eval_string("{datemark}"));
//str
等于
"RB={datemark}
//
生成
"Name={id}"
内容
strcpy(delstr, "Name=");
strcat(delstr, id);//ID
是字符数组
sprintf(downloadfile,
lr_eval_string("{linkname}"), lr_eval_string("{uid}"));
// sprintf
格式的用法
三、 文件处理
"c:%s%",
(1)
打开或创建文件
if((file = fopen(downloadfile, "wb")) == NULL)
//downloadfile
的格式是:
c:
表示文件的路径,没有这个文件 就会创建
文件。
"wb"表示文件的属性
文本文件
,W可写B表示2进制还有是R可读T表示的是.TXT
(2) write
写文件
fwrite(lr_eval_string("{fcontent}"), filesize, 1, file);
第一个参数:
lr_eval_string("{fcontent}")
联获得
表示要写到文件里的内容它可以用关
web_reg_save_param("fcontent","LB=","RB=","SEARCH=BODY",LAST)
,当点击一个 下载的链接,那么就回返回一个
HTML的内容
其中BODY里面的内容就是我们要下载的文件内容。
第 二 个 参 数 : 表 示 文 件 的 大 小
filesize
web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
来获得,具体查看帮助。 第三个参数:表示文件写入次数。
第四个参数:FILE LONG型的数,记录创建文件的路径和文件的属性
(3)
关闭文件
fclose(file);
四、 消息的输出
lr_output_message("File open failed!");
输出到 运行结果中去
五、
Step download timeout (120 seconds)
这是一个经常会遇到的问题,解决得办法走以下步骤:
1修改run time setting
别建议修改为
中的请求超时时间,增加到
600s,其中有三项的参数可以一次都
设置完了后记住还需要在
修改了,
HTTP-request connect timeout
,
HTTP-request receieve timeout
,Step download timeout
,分600、600、5000;
run time setting
中设置相应的参数;
control
组件的option
的run time setting
2、办法一不能解决的情况下,解决办法如下:
设置
runt time setting
中的
internet protocol-preferences
中的
advaced
区域有一
个wi nlnet replay in stead of sockets选项,选项后再回放就成功了。 切记此法只对
wi ndows
系统起作用,此法来自
zee的资料。
六、 问题描述
Connection reset by peer
这个问题不多遇见,
间。
解决办法:Run-time setti ng
(sec),可以稍微设大一些”;
七、 问题描述
connection refused
这个的错误的原因比较复杂,
的操作系统方式也不同;
也可能很简单也可能需要查看好几个地方, 解决起来不同
窗口中的 ‘
In ternet Protocol
' — '
Prefere nces
'设
一般是由于下载的速度慢,导致超时,所以,需要调整一下超时时
置
set advaneed options
(设置高级选项),重新设置一下"HTTP-request connect timeout
1、 首先检查是不是连接
weblogic服务过大部分被拒绝,
(连接池数*Statement Cache Size
需要监控weblogic的连
接等待情况,此时需要增加
acceptBacklog,每次增加25%来提高看是否解决,同时还需要
)的值应该小于等于 增加连接池和调整执行线程数,
oracle数据库连接数最大值;
2、 如果方法一操作后没有变化,此时需要去查看服务器操作系统中是否对连接数
修改其中的连接限制数, 还有tcp连接等待时间 做了限制,AIX下可以直接vi文件limits
项;
八、 问题描述
open many files
问题一般都在压力较大的时候出现,
有最大值限制造成,解决办法:
间隔大小,wiodows类似,只不过
wendows修改注册表,具体修改方法查手册,注册表中有
TcpDelayTime
由于服务器或者应用中间件本身对于打开的文件数
1、
2、
修改操作系统的文件数限制,
aix下面修改limits
下的nofiles
限制条件,
weblogic的文件,
增大或者设置为没有限制,尽量对涉及到的服务器都作修改;
方法一解决不了情况下再去查看应用服务器
修改其中的nofiles
文件max-nofiles
数增大,应该就可以通过了,具体就是查找到
nofiles
方法,修改其中else条件的执行体,把文件打开数调大;修改前记住备份此文件,防止修
改出错;
九、 问题描述
has shut dow n the conn ecti on prematurely
一般是在访问应用服务器时出现,大用户量和小用户量均会出现;
来自网上的解释:
1>应用访问死掉
小用户时:程序上的问题。程序上存在 数据库的问题
2>应用服务没有死
应用服务参数设置问题
例如:
在许多客户端连接
Weblogic应用服务器被拒绝,而在服务器端没有错误显示,则有可
能是Weblogic中的server
元素的AcceptBacklog
属性值设得过低。如果连接时收到
conn ection refused
消息,说明应提高该值,每次增加
Java连接池的大小设置,或
3>数据库的连接
在应用服务的性能参数可能太小了
数据库启动的最大连接数(跟硬件的内存有关)
25%
JVM的设置等
以上信息有一定的参考价值,实际情况可以参考此类调试。
如果是以上所说的小用户时: 程序上的问题。程序上存在数据库的问题,
主要是程序中执行效率很低的
那就必须采用
更加专业的工具来抓取出现问题的程序,
sql语句,weblogic
可以采用introscope
定位,期间可以注意观察一下
jvm的垃圾回收情况看是否正常,我在
实践中并发500用户和600用户时曾出现过jvm锯齿型的变化,上升下降都很快,这应该是 不太正常的;
十、问题描述
Failed to connect to server
这个问题一般是客户端链接到服务失败,
机器),一个网络延迟严重,解决办法:
原因有两个客户端连接限制(也就是压力负载
1、 修改负载机器的tcpdelaytime
注册表键值,改小;
2、 检查网络延迟情况,看问题出在什么环节;
建议为了减少这种情况, 办法一最好 测试前就完成了,保证干净的网络环境, 每个负载
机器的压力测试用户数不易过大,尽量平均每台负载器的用户数,
就很小了。
这样以上问题出现的概率
版权声明:本文标题:性能测试工具LoadRunner实验报告 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1706177277a174490.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论