压测随笔

loadrunner常用api

//根据左右边界获取需要的返回信息保存在变量中

web_reg_save_param("task_response",
"LB=HTTP/1.1 ",
"RB= ",
"Search=headers",
// "SaveOffset=3",
//"SaveLen=8",
// "IgnoreRedirections=Yes",
LAST);

//

strcmp(lr_eval_string("{log_response}"),"200") == 0

//添加http信息头

web_add_header("Accept-Encoding","gzip, deflate"); 

web_add_header("Content-Type","text/plain");

web_add_header("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");

web_add_header("Content-Encoding","gzip");

//定义启动一个事务 结束一个事务带判定结果

lr_start_transaction("tr_task");

lr_end_transaction("tr_lask", LR_PASS);

 lr_end_transaction("tr_lask", LR_FAIL);

//http请求方式

web_url("nginx",
"URL=http://game.chongzhuowenhua.com/tankonline/?cmd=login&type=0&version=0.1",
"Resource=1",
"RecContentType=application/json",
"Referer=",
LAST);

web_submit_data("default.aspx",

"Action=http://lazarus/flightnet/default.aspx",

"Method=POST",

"TargetFrame=",

"RecContentType=text/html",

"Referer=http://lazarus/flightnet/",

"Snapshot=t7.inf",

"Mode=HTML",

ITEMDATA,

"Name=grpType", "Value=radRoundtrip", ENDITEM,

"Name=lstDepartingCity", "Value=DEN", ENDITEM,

"Name=lstDestinationCity", "Value=LAX", ENDITEM,

"Name=txtDepartureDate", "Value=8/19/2003", ENDITEM,

"Name=txtReturnDate", "Value=8/19/2003", ENDITEM,

"Name=txtQuantity", "Value=1", ENDITEM,

"Name=radClass", "Value=1", ENDITEM,

"Name=radSeat", "Value=1", ENDITEM,

"Name=btnAvailableFlights", "Value=Next >", ENDITEM,

LAST );

web_custom_request("tr_task",
"URL=http://172.18.245.21:5000/api-webpage-brush/webPage/getTask",
"Method=post",
"Resource=0",
"Referer=",
"Mode=HTTP",
"BodyBinary={taskData}", //将需要发送的数据加密处理转成16进制、 utf-8编码文件,并指向taskData变量
LAST);

准备工作

  环境搭建(需要几台服务器 几个节点)

  数据准备 

  脚本编写 、联调单次、多次数据校验,是否做了加密处理

  场景设计 业务和系统架构两方面分析  选出实际生产环境可能会发生的场景

进行压测

  关注点 主要分为指标 和 日志

  reponse time

  HIts/sec

  TPS

  throughout/sec

-------------------------------------

  cpu

  mem

  IO

  swap

  net

  jvm

  GC情况 主要关注FullGC 一般来讲  FullGc可以完全避免  10minute 发生1次fullgc  消耗1s   1minute发生一次  monitor gc 消耗10ms是可以容忍的

 

原文地址:https://www.cnblogs.com/heishi/p/8203465.html