Jmeter test website concurrency

Reprinted from: https://www.cnblogs.com/qqbook/p/7705483.html

How to test the performance (concurrency) of a website?

JMeter website concurrency test

Apache JMeter is a Java-based stress testing tool developed by the Apache organization. Used for stress testing of software. It was originally designed for web application testing but later expanded to other testing areas. It can be used to test static and dynamic resources such as static files, Java servlets, CGI scripts, Java objects, databases, FTP servers, etc. JMeter can be used to simulate huge loads on servers, networks or objects to test their strength and analyze overall performance under different stress categories. In addition, JMeter can perform functional/regression tests on the application, and verify that your program returns the results you expect by creating a script with assertions. For maximum flexibility, JMeter allows the use of regular expressions to create assertions. Not much to say: Direct operation: Since JMeter is developed using java, it needs a java operating environment to run. Anyone who has been in touch with Java knows that the establishment of a Java environment is not something we are discussing now, so it won’t. Save yourself.

 

1. Download JMeter

 

Download the latest version from the official website:  http://jmeter.apache.org/download_jmeter.cgi  , in English, you know.

Friends who don’t speak English well  :  http://www.quzhuanpan.com/home/sourceList.jsp?type=6 , Chinese download address

 

2. Start JMeter

Not much to say, just go to the picture above: first unzip apache-jmeter-2.9, enter the bin directory: click jmeter.bat. Start the software

 

 

Start interface:

 

 

1) Establish threads. Simulate multi-user access: the steps are as follows

 

 

 

Why create a thread group? The reason is simple, because we have to simulate multiple threads (users) to access the web site. In the thread properties section, the number of threads is how many threads are started. For example, I fill in 10 here, and Ramp-Up Period (in seconds) indicates how much time is allowed between threads, and the unit is seconds. /10=1 means that the website is requested every 1 second among 10 threads. Number of cycles: 60 threads are counted as one time after running. The number of cycles is how many times such a request process runs. I filled in 2 in the test here. Every time you modify a setting, don't forget to save it.

 

2) Set up request server, pressure link and other information

 

The next natural thing is, what is the website address we want to test? What is the link? So now we will set up this information. Right-click the thread group we just created, and in the pop-up menu, select Add->Sampler->Http Request, and the following interface will pop up:

path:

If you just stress test a link, just fill in a link directly, such as https://m.kkdshu.com/, but this is not the case in most cases. We need multiple links here, just like at the beginning As mentioned, we need to save multiple links to a text file and read them randomly for stress testing. We can do this, as shown in the figure:

Select _StringFromFile in the select a function drop-down list, and then create a new test file C:\Users\root\Desktop\apache-jmeter-2.9\test.txt on the machine, in the first line (you can also not in the first line Fill in the path of the test file in the value of ), as shown below:

 

Then click the "Generate" button, and a string will be generated in the text box on the left side of the button, such as:

${__StringFromFile(C:\Users\wukong\Desktop\test.txt,,,)}

In the test.txt file, we write a URL link per line, in the following format:

If the address is: www.kkdshu.com. Then. The content in test.txt is the relative address; such as

 

In this way, when we are not requesting, we will randomly select URLs from test.txt for stress testing.

Another point worth noting is that if there are Chinese in the parameters, garbled codes may appear during operation. At this time, you need to pay attention to the encoding settings in Jmeter that are consistent with the web page encoding you want to request.

The options under the path text box can be done by default. Use multipart/form-data for HTTP POST is when there are attachments in the request. Generally, you don’t need to select it.

3) View running results

Right-click the thread group, and select Add -> Listener -> Query the results in the form in the pop-up menu, as shown in the figure below:


 

The attributes are as follows:

  • Sample: The serial number of each request
  • Start Time: the start time of each request
  • Thread Name: the name of each thread
  • Label: Http request name
  • Sample Time: The time spent in each request, in milliseconds
  • Status: Request status, if it is a check, it means success, if it is a cross, it means failure.
  • Bytes: the number of bytes requested

There are several more parameters below:

  • Number of samples: That is the number of requests mentioned above. In the case of success, it is equal to the number of concurrent times you set multiplied by the number of cycles
  • Average: the average time of each thread request
  • Latest sample: indicates the time when the server responded to the last request
  • Deviation: The server response time changes and the size of the measured value of dispersion.

Guess you like

Origin blog.csdn.net/ClearLoveQ/article/details/108582374