Introduction to stress testing and testing tool jmeter

Stress testing examines the maximum load that the system can withstand under the current hardware and software environment and helps to find out where the system bottlenecks lie. The pressure test is to maintain the online processing capacity and stability of the system within a standard range, so as to know what to expect.
Using stress testing, we can hopefully find many kinds of bugs that are more difficult to find with other testing methods. There are two types of bugs : memory leaks, concurrency and synchronization .
An effective stress testing system will apply the following key conditions : repetition , concurrency , magnitude , random variation .

1. Performance indicators

  • Response time ( Response Time: RT )
Response time refers to the time it takes for the user to initiate a request from the client to the end when the client receives the response returned from the server.
  • HPS ( Hits Per Second ): The number of hits per second, the unit is times / second.
  • TPS ( Transaction per Second ): The number of transactions processed by the system per second, the unit is pen / second.
  • QPS ( Query per Second ): The number of queries processed by the system per second, and the unit is times / second.
For Internet business, if some business has one and only one request connection, then TPS=QPS=HPS . Generally, TPS is used to measure the entire business process, QPS is used to measure the number of interface queries, and HPS is used to represent the number of queries to the server. Click Request.
Regardless of TPS , QPS , HPS, this indicator is a very important indicator to measure the system processing capability, the bigger the better, according to experience, in general:
  • Financial industry: 1000TPS~50000TPS , excluding Internet-based activities
  • Insurance industry: 100TPS~100000TPS , excluding Internet-based activities
  • Manufacturing industry: 10TPS~5000TPS
  • Internet e-commerce: 10000TPS~1000000TPS
  • Internet medium-sized website: 1000TPS~50000TPS
  • Internet small website: 500TPS~10000TPS
  • The maximum response time ( Max Response Time ) refers to the maximum time from when the user sends a request or instruction to when the system responds (response).
  • The minimum response time ( Mininum ResponseTime ) refers to the minimum time from the user to send a request or command to the system to respond (response)
  • 90% response time ( 90% Response Time ) refers to the response time of all users sorted, the 90% response time.
From the outside, performance testing mainly focuses on the following three indicators
  • Throughput: The number of requests and tasks that the system can handle per second.
  • Response time: The time it takes for a service to process a request or a task.
  • Error rate: The proportion of requests that result in errors in a batch of requests.

Two, jmeter

 

(1) JMeter installation

https://jmeter.apache.org/download_jmeter.cgi
Download the corresponding compressed package, decompress and run jmeter.bat

(2) JMeter pressure test example

1. Add thread group

 

Detailed explanation of thread group parameters:
  • Number of threads: number of virtual users. A virtual user occupies a process or thread. How many virtual users are set here is also how many threads are set.
  • Ramp-Up Period (in seconds) preparation time: How long does it take for the set number of virtual users to start up. If the number of threads is 10 and the preparation time is 2 , it takes 2 seconds to start 10 threads, that is, to start 5 threads per second.
  • Number of loops: The number of times each thread sends a request. If the number of threads is 10 and the number of loops is 100 , then each thread sends 100 requests. The total number of requests is 10*100=1000 . If " Forever " is checked , then all threads will send requests all the time, and stop running the script once it is selected.
  • Delay Thread creation until needed : Delay thread creation until needed.
  • Scheduler: Set the start time and end time of thread group startup ( when configuring the scheduler, you need to check the number of cycles as forever)
  • Duration (seconds): Test duration, will override end time
  • Startup delay (seconds): The test delays the startup time, which will override the startup time
  • Startup time: Test the startup time, the startup delay overrides it. When the startup time has passed, the current time will also override it when manually simply testing.
  • End Time: The end time of the test, the duration will override it.

2. Add HTTP request 

 

3. Add a listener

 

4. Start pressure measurement & view analysis results

Result analysis:

  • Confirm the error rate with the development to determine whether errors are allowed or within what range the error rate is allowed;
  • If the number of throughput requests per second is greater than the number of concurrent requests, it can be increased slowly; if the throughput is less than the number of concurrent requests when the performance of the stress-tested machine is good, it means that the number of concurrent requests cannot be increased any more. Slowly decrease to find the optimal number of concurrency;
  • After the pressure test is over, log in to the corresponding web server to view performance indicators such as CPU and analyze the data ;
  • For the maximum tps , keep increasing the number of concurrency until the tps reaches a certain value and starts to decline, then that value is the maximum tps .
  • Maximum concurrency: The maximum concurrency and the maximum tps are different probabilities. Generally, the concurrency is continuously increased. After reaching a certain value, the server has a request timeout, and this value can be considered as the maximum concurrency.
  • There is a performance bottleneck in the pressure test process. If the cpu , network and cpu viewed by the task manager of the press machine are normal and do not reach more than 90% , it can indicate that there is a problem with the server and the press machine has no problem.
  • Considerations affecting performance include :
    • Aspects of database, application, middleware ( tomact , Nginx ), network and operating system
  • First consider whether your application is CPU -intensive or IO- intensive

(3) JMeter Address Already in use error resolution

The problem with the port access mechanism provided by windows itself.
Windows provides ports 1024-5000 for TCP/IP connections and takes four minutes to recycle them. As a result, the port is full when we run a large number of requests in a short period of time.
  1. In cmd , use the regedit command to open the registry
  2. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters 下,
    1. Right click on parameters and add a new DWORD named MaxUserPort
    2. Then double-click MaxUserPort , input the numerical data as 65534 , and choose decimal as the base (if it is distributed operation , both the control machine and the load machine need to do this)
  3. After modifying the configuration, remember to restart the machine to take effect
https://support.microsoft.com/zh-cn/help/196271/when-you-try-to-connect-from-tcp-ports-grea
ter-than-5000-you-receive-t
TCPTimedWaitDelay 30

 

Guess you like

Origin blog.csdn.net/m0_62946761/article/details/132125476