How to properly stress test web applications?

Web application, in layman’s terms, is a website, which mainly relies onbrowser to access it Function.

Then how to properly conduct a websitestress test?

When it comes to stress testing, we think of server-side stress testing. In fact, this is one-sided. A complete stress test includes server-side stress testing and front-end stress testing.

1. Web application (website) stress test scope, including front-end and back-end

Web applications (websites) were not separated into front-end and back-end at first (so PHP, a language specifically used for building websites, was very popular during that time). Later, as the website became more and more functional, the architecture without separation of front-end and back-end became inefficient. and falling behind, at this time the architecture application of separation of front and back ends was born (PHP has since declined).

In the architecture mode where the front and back ends are separated, the front and back end engineers agree on the data interaction interface to achieve parallel development. Therefore, a web application (website) actually contains two independent parts, the front end and the back end.

Separation of front and back ends

Google DoubleClick research shows that if a webpage takes 1 second to load, users will lose 10%, and if the loading time exceeds 3 seconds, users will leave.

Therefore, for a new web application, in addition to common server-side stress testing, front-end stress testing is also indispensable. A complete web application stress testing process is shown in the figure below:

2. Front-end and back-end stress testing process

step1. Determine the pressure test scope and pressure test target

Stress test scope: If it is a new project, in principle, all functions and interfaces must be stress tested. If there are new requirements for old projects, the scope of impact needs to be assessed to determine whether the old functions and interfaces require stress testing.
Stress test target: If it is a new project, an estimated target should be set based on the basic situation and experience in the industry; if it is an old project, the historical traffic peak can be used as a reference target.

step2. Develop a stress testing plan
Based on the expected goals of the previous step, formulate a stress testing plan. Specifically include: stress test environment, stress test time, relevant person in charge, testing tools or platforms, and acceptance criteria.
Stress test environment: In order to restore the real stress scenario, the pre-release environment or the production environment is generally selected for stress testing.
  
Stress test time: Stress testing is usually performed after the functional test or interface test is completed.
  
Stress testing tools or platforms: Front-end stress testing can use platforms such as PageSpeed, while back-end stress testing generally uses tools such as jmeter and loadrunner. (See Supplement 1 and Supplement 2 for details)
  
Acceptance criteria: Generally speaking, the estimated value of the pressure test target must be achieved. 3. Stress test preparation Stress test machine: Prepare the stress test machine group (for back-end use) for sending requests. Server: Since the stress test traffic will be high, server clusters need to be prepared in advance to handle traffic or expand capacity. Data preparation: Prepare for stress testing Generally speaking, the data should be distinguished from the real data. Prepare a stress test script and add identifiers to distinguish it from real traffic. 4. Implement pressure test Apply pressure: During the process of applying pressure, start with a smaller flow rate and gradually increase the pressure. Observation: In the process of gradually increasing pressure, it is necessary to observe data such as rt, error (error reporting rate), server CPU, memory usage and other data. If an abnormality is found, the pressure test must be stopped in time and pending investigation and Perform a stress test after solving the problem. 5. Stress test observation & bottleneck analysis How to judge the endurance of the application? Observe the error rate, response time and other indicators during the stress test. If there are abnormal indicators, it means that the traffic has reached the current bottleneck, and the stress test analysis needs to be stopped and the reasons need to be investigated. The following are several common exception analysis methods: ·The success rate does not meet the standard: check the error log, troubleshoot the root cause of the error, and perform performance tuning · Chapter Two situations: There are no abnormalities in indicators such as rt and error rate, but the server CPU and memory usage are about to reach the bottleneck, and the expected stress test target has not been reached. At this time, it cannot be solved through tuning, and more servers need to be added. · The first situation: Server CPU, memory and other indicators are not stable. The bottleneck has been reached (usually when the usage rate reaches 70%-80%), and indicators such as qps, rt, error rate, etc. are abnormal. At this time, you need to repeat the previous step to troubleshoot and optimize. After the bottleneck tuning occurs in the previous step, continue to increase pressure and observe various indicators: When do you need to add servers? · The throughput does not meet the standard: If the success rate and response time meet the standard, it is recommended to continuously increase the number of simulated users, re-stress the test, and check the test results · The response time does not meet the standard: compare error logs, link tracking results, server performance indicators, database/middleware monitoring indicators to find the specific reasons for the long response time
  

  


  

  

  

  


  

  

  


  

  

  

  

  

  

  


  

  

Server indicator monitoring 

6. Acceptance  

Reaching the expected goal: If the expected goal is achieved, the stress test can generally be considered passed.

Failure to reach the expected goal: If the expected goal is not reached due to various reasons (resources, budget, etc.), the product manager and R&D manager need to confirm the stress test results.​  

7. Send stress test report  

8. Project goes online  

After the previous steps are completed, the project can be released and launched.

3. How to supplement the front-end stress test  

Google developers proposed a RAIL model to measure the front-end performance of an application, namely response, animation, idle and load.

The widely used key metrics of the RAIL model are as follows:

Tools used: PageSpeed

PageSpeed ​​is an open source automation tool from Google. Just install the PageSpeed ​​extension and run it.  

The report results are as follows:

This tool is rich in functions, the report is also very detailed, and optimization suggestions are given. You can make corresponding optimizations based on the test report.​  

Four: How to supplement the back-end stress test  

The backend refers to the server, and the backend stress test is the server stress test, which can also be called server stress test.

During the stress testing process, the following indicators are generally focused on: qps (number of requests processed), rt (response time), error (error reporting rate), cup (cpu usage), mem (memory usage) ), load (load), traffic (network rate).
 
Find the performance bottleneck of the server by observing key indicators such as qps, rt, error, etc. If it is lower than expected, it needs to be tuned.

Through stress testing, server bottlenecks can be discovered in advance and optimized in time to prevent the website from crashing as soon as it goes online.

Tools: Commonly used tools for stress testing include LoadRunner and Jmeter.

Jmeter is an open source and free testing tool developed in Java. It is mainly used for performance testing. JMeter can be used to simulate huge loads on servers, networks or objects. It has a rich graphical interface + script configuration , convenient and easy to use.
  
LoadRunner is a load testing tool that predicts system behavior and performance. Confirm and find problems by simulating tens of millions of users to implement concurrent loads and real-time performance monitoring.


              [Below is the most complete software test engineer learning knowledge architecture system of 2023 I compiled]


1. Python programming from entry to proficiency

2. Practical implementation of interface automation projects  

3. Web automation project actual combat


4. Practical implementation of App automation project  

5. Resumes of first-tier manufacturers


6. Test and develop DevOps system  

7. Commonly used automated testing tools

8. JMeter performance test  

9. Summary (little surprise at the end of the article)

life is long so add oil. Every effort will not be disappointed, as long as you persevere, you will eventually be rewarded. Cherish your time and pursue your dreams. Don’t forget your original intention and forge ahead. Your future is in your control!

Life is short and time is precious. We cannot predict what will happen in the future, but we can control the present. Cherish every day, work hard, and make yourself stronger and better. With firm belief and persistent pursuit, success will eventually belong to you!

Only by constantly challenging yourself can you constantly surpass yourself. Keep pursuing your dreams and move forward bravely, and you will find that the process of struggle is so beautiful and worthwhile. Believe in yourself, you can do it!​ 

Finally, I would like to thank everyone who reads my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, if you can use it, you can take it directly:

This information should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can also help you!​ 

Guess you like

Origin blog.csdn.net/qq_48811377/article/details/135017467