当前位置:网站首页>JMeter piezometric interface programming North

JMeter piezometric interface programming North

2022-06-11 03:41:00 PostTruth

In the field of e-commerce , Every time we go to various activities , what 618, A double tenth , 12-12 , All kinds of preferential activities come in a stream , A huge challenge for marketing tools , therefore , The pressure test of marketing related systems is to ensure the stable operation of the system , Necessary means to deal with sudden traffic .

Coupon system is a big killer in marketing tools , Its stability guarantee is essential .

The following mainly introduces the pressure measurement process of the coupon system I am responsible for in response to the sudden flow of the double 11 :

1. Preparation before pressure test

download Pressure measuring tool : Jmeter

Count the data of each pressure test interface in advance : daily QPS, 99 Line , Double 11 estimated QPS

Pressure measurement thread count calculation : 1000/ Interface 99 Line x Number of threads = The goal is QPS

 daily QPS: When the system is inactive  QPS,  Go to the system monitoring market to check ,  Such as  cat
99 Line : 99%  Request time for (ms)
 Double 11 estimated QPS:  Each company has different regulations ,  Our company is daily  QPS  Of  50-100  times , Select according to the interface business scenario 
 Number of threads :  During pressure measurement  Jmeter  Number of threads filled in 

start-up jmeter

$ jmeter                                                                                                                                                         [10:17:24]
WARNING: package sun.awt.X11 not in java.desktop
================================================================================
Don't use GUI mode for load testing !, only for Test creation and Test debugging.
For load testing, use CLI Mode (was NON GUI):
   jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]
& increase Java Heap to meet your test requirements:
   Modify current env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m" in the jmeter batch file
Check : https://jmeter.apache.org/usermanual/best-practices.html
================================================================================

from jmeter The startup information shows that , We should use GUI Write pressure test script , Using the command line jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder] Carry out pressure test

Jmeter Go to find a place in the evening demo Case study , You can operate it yourself , Let me mainly introduce the production level Jmeter scripting

Jmeter scripting

Create a new folder : testplan

open jmeter ,

Adjust the language style to Chinese , options -> choose Language -> chinese

establish testplan:

img

Save to We Created testplan Folder

image-20211019110654135

Right click to add HTTP Request defaults

image-20211019110928389

Fill in your pressure test environment , Common script tests use test Environmental Science

image-20211019111049633

add to JSON Assertion : When the response code by 10000 When it comes to success

image-20211019111208486

According to your system request parameters , add to Corresponding request header : HTTP Header Manager

image-20211019111340456

add to : Aggregation report : You can see Interface pressure measurement information

image-20211019111503938

Complete the general steps above , Next, start the real interface pressure test :

testplan Right click , add to Thread group , The concept of thread group can be understood as a specific pressure measuring interface , Include request address , Parameters , Number of threads , They are all set up here

image-20211019111806006

Number of threads : According to the above formula , Calculate for yourself

Ramp_Up: stay 10 Step by step within seconds 100 Threads

The duration of the : Prevent the pressure measuring interface from always executing , Make a decision The duration of the

add to HTTP request

image-20211019112057573

Focus on : ${calcReceivedPromotionForProductList} This is our request parameter set , Because we want to simulate the real user request as much as possible , One way is From the online log , Pull out a batch of requests , Save in file , Let the pressure measuring interface read , and ${calcReceivedPromotionForProductList} It is the request parameters that we pull from the line . Here's how , How to add this request parameter set

add to : CSV Data file settings

image-20211019112509396

In our testplan Create in folder Folder : requests, Then build : calcReceivedPromotionForProductList-test.txt file , Inside is the request parameters , I use newline splitting here

image-20211019112656990

Request parameters are written , Add another Observe the fruit tree , It is used to view the response of each interface during pressure measurement , Including in and out parameters :

image-20211019112825711

thus , A pressure measuring interface is written , We click Jmeter Start button on the menu bar , Test and view the aggregation report

image-20211019113041865

I wrote two thread groups here , That is, two interfaces , You can follow the above steps , Add the pressure test interface you need

On line pressure test

according to Jmeter The advice of , On line pressure test , We can't use GUI, You need to use the command line .

Let's take the pressure measurement interface above for example , We Jmeter The command is executed as follows :

jmeter -n -t ./ Coupon -lzg.jmx -l ./result/result.txt -e -o ./webreport

 Coupon -lzg.jmx  Plan file path for test 
/result/result.txt  Path to test results file 
/webreport  by web Report save path .

Pay attention to our folders : testplan Execute this command under , It's used in We all use Relative file location , The advantage of this is , We can put testplan The folder is packed as a compressed package , Upload it to our springboard to execute the pressure test request

image-20211019113551571

Command line access testplan Under the folder , perform

image-20211019113844109

You can see testplan There is one more under the folder Test report

image-20211019113923449

Double click to open and view the pressure test results in the browser

image-20211019114026691

thus , The compilation of an on-line pressure measuring interface has been introduced , Jmeter There are some more advanced features , If you are interested, you can go to the official website to see its introduction .

原网站

版权声明
本文为[PostTruth]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020553546423.html