Jmeter actual combat: performance test that can be understood with 0 foundation (recommended collection)

Often hear performance? What is performance, how do people who have never done performance testing get started? This article is very suitable for students with zero foundation to read. After reading it, you can basically know the whole process of performance testing.

Performance Indicators
 1. What is Performance Testing

Under certain circumstances, use tools to simulate whether the response time, throughput and other indicators of the user load system meet the requirements.

2. Performance indicators

Basically, anyone who has done performance testing knows the word performance indicators. Generally, after the script is successfully executed, the server performance will be judged by indicators to determine whether it meets the current business needs. Moreover, during interviews, it is often asked which indicators to use to observe server performance. .

Performance indicators can be observed from the following five aspects:

Concurrent number: Simulate the number of users. For example, Taobao double 11 simulates the operation of adding tens of millions of users to the shopping cart. The number of users here is the concurrent number.

Response time: the time to complete a transaction (client-network-server-database), the time to complete a specific scenario, such as the completion time for tens of millions of users to perform the operation of adding to the shopping cart, the most famous principle is the 2-5-8 principle .

Stability: Whether there is any abnormality in the system in the long-term running scene, and the system runs normally for 12-24 hours without error reporting.

Resource usage: CPU\memory usage, by observing the CPU\memory usage of the server, generally <=80%

Think time: In order to simulate real user scenarios, you need to add thinking time when designing scripts. For example, it takes 2-3 seconds to reach the checkout page after adding to the shopping cart after execution. This time can be considered as thinking time.

3. Performance testing process

Roughly divided into requirements analysis->indicator analysis->scenario use case design->script use case design->build test data->script development->execute and collect running results->output test report->performance tuning and regression .

Selection of performance testing tools
At present, the mainstream performance testing tools are Jmeter and Loadrunner, and most companies basically use Jmeter, because loadrunner has the following three disadvantages:

1) The price is expensive, generally charged according to the agreement and the number of virtual users;

2) No secondary development, such as implementing additional functions, does not support scripts written by oneself;

3) The maximum number of concurrency supported is 50, and there is a limit to supporting a large number of concurrency.

So this article introduces the use of Jmeter tools.

Test plan
1. Clearly implement the function

If you don't know which scenarios need to be tested, you can consider the following aspects:

For example, in the login scenario, almost all system and system operations are completed on the basis of login, so the general login scenario is within the plan

Functions with a large number of users: the shopping cart function of the shopping system, the payment function, etc.

Important functions: core business functions of the system, payment, etc.

2. Determine the indicator value

Most of the general indicator values ​​will be provided by the following product/project managers according to the user's usage habits, but some small companies have imperfect processes, and each indicator needs to be formulated by the testers themselves to provide some ideas.

Calculated according to the formula

QPS: Generally find the highest peak value in a day. For example, Taobao.com is the peak value at 10 am, and the PV peak value is 5208, then its QPS=5208*0.8/(3600*0.2), where the 2-8 principle means 80% The business volume is completed by 20% of the time, and 3600 is converted from hours to seconds.

concurrent number

There are generally 3 methods:

A. According to the formula QPS=concurrency number/average response time, where the time and qps are known, the number of concurrency can be obtained

B. Estimate based on the number of online activities

C. Based on past experience

Take the number of online activities as an example:

First specify the number of 3 users

Number of system users: the number of people registered in the system

Number of online users: Some of the registered users of the system are zombie users. For those who do not use the product, the number of users who use product functions after excluding this part is the number of online users.

Number of concurrent users: Calculate the average number of concurrent users: C = nL/T, where T is the assessment duration, n is the number of users logging into the system, and L is the login duration. Generally, the assessment duration is 1 day, and the login duration is 2 hours. For example, a system The number of users is 500, then C=500*2/8=125

Generally, in actual work, according to the company's business needs, small companies prefer not to use formula calculations, first set a value by themselves to see the server response, and then gradually increase it, which is time-consuming. Analyze server performance bottlenecks for further analysis.

Examples of script recording
Here are a few examples that I think are useful to everyone in actual work.

1. Recording script - jmeter/badboy

Premise: Each control has been set up (add test plan - proxy server - thread group - only once controller - transaction controller, etc.).

Jmeter recording login script

1) IE browser settings proxy

First find the LAN settings dialog box in the browser, fill in the proxy server ip address (the jmeter tool uses the computer ip address), the default port is 8888, generally do not need to be changed, click OK.

2) The proxy server sets your target controller, which controller you want to put the script in and select which one, and the login here needs to be debugged together with other functions, so select only one controller.

 3) For the proxy server, click the start button in the above figure, enter the URL in the ie browser -> enter the account number and password, and click to execute the login operation.

4) After successful login, click the stop button in the upper left corner of jmeter.

 

5) View the session under the login controller, and a series of session scripts executed during the login process will appear.

 6) Debug and run to view the result tree. If there is no red record, it is successful. Generally, there is a return value under the response data.

2. Badboy recording login interface

Why use Badboy to record, sometimes when recording with Jmeter, the recorded content will not appear, causing the process to fail. For example, the drop-down box selection actually has content, but the content does not appear when recording. You can try to use badboy to try it out.

1) Start badboy, enter the ip address and click Run Annie.

 2) The login interface is displayed on the right side of the page, click the recording icon, enter the user name and password to log in, and click to stop running.

3) After stopping the recording, select File -> Check Export to JMeter.

4) Open JMeter to import the script just now, and the badboy script has been recorded successfully.


The following are supporting learning materials. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

 Information acquisition method:

Guess you like

Origin blog.csdn.net/qq_73332379/article/details/132669144