Web interface Performance Test summary based on HTTP request
The purpose of the pressure measurement: for the purpose of Web interface pressure measurement is to look at the pressure on the database to see whether the CPU of the server is up to the warning value, whether the memory has a cataclysmic or even leak, the error rate of response results, and the database server read and write the situation is normal and so on.
Preparation of the test environment
We are ready to test the server and press and establish a connection between them.
Pressure Measurement Server
To provide the service, that is, our test server, which is released is the pressure measurement branch, we first need to pull a pressure measurement based on the benchmark branch and push to the far end, and then the development of the Code to the test branch and push to the remote, published to the pressure test server. In general, our test server is a single-node tomcat, and the online environment is often a load-balanced cluster of multiple servers.
Pressure machine
Presses are used to provide pressure, and we do concurrency through JMeter. In the actual test, the press can choose the machine, but also can choose the pressure measurement server.
The difference is: The machine has JMeter interface, the test results are very intuitive, and the pressure measurement server is no UI;
Advantages and disadvantages are: the advantages of selecting this machine is the pressure test results display convenient, Windows graphical test results display, but the disadvantage is that the network between the computer to the pressure measurement server situation will affect the accuracy of the test results. This problem does not exist on the pressure measurement server.
Establish contact
The hosts are switched to the pressure measurement environment on the press, so that the pressure measurement environment can be pressurized.
Preparation of test data
To put pressure on the database, we analyze the HTTP request to find the parameters that can stress the database (this parameter is often used to interact with the database, for example, to make a pruning check), then mock the parameters, make enough data and satisfy the complexity of the parameters, Indirectly put pressure on the database by means of concurrent HTTP requests. This is done for data with parameters to simulate a sufficient variety of HTTP requests. And then we'll insert a certain amount of data into the database table to meet the data volume requirements of the database and simulate the amount of data in the database tables in real-world situations. The former is to do data for user behavior, the latter is to simulate the current situation of the database, both of which provide simulation data support for the pressure measurement.
Preparation of the pressure test script
We use JMeter to develop a pressure measurement plan, create a pressure measurement plan in JMeter, add a thread group, and then add HTTP requests, aggregate reports, view result trees, graphical results, and so on in a threaded group. Debugging is OK, the script can run through, you can set thread properties (set concurrency) on the thread group, and set the continuous concurrency time in the scheduler configuration for stress testing. We can do this machine presses, in the local switch hosts to the pressure measurement environment for pressure measurement. You can also configure the JMeter script to connect the JMeter folder together with the package zip file sent to the pressure test Linux server, and then in their own directory "unzip Jmeter.zip", "CD" to the extracted directory, "chmod 777 jmeter.sh" Add execute permissions, and then "./jmeter.sh-n-T your pressure test. jmx-l Result.jtl" To perform the pressure measurement, the results of the test will be saved to the Result.jtl file, in the current directory. We can observe the results of the test during the server execution, or you can view and analyze the Result.jtl file on the Linux server after the test is finished (or you can download the file to this machine via the "SZ result.jtl" command. The specific download storage path is set in the SecureCRT options->session options->x/y/zmodem). During the actual pressure measurement process, we constantly modify the number of threads and change the concurrency amount. As the number of concurrent threads increases, the throughput per second of this concurrency is the bottleneck when the average response time starts to increase significantly and the throughput is almost constant per second.
Problems encountered in the process of pressure measurement
During the pressure test, you may encounter "Nohttpresponseexception (the target server failed to respond)". This is due to a problem with the JMeter itself setting, Modify the Httpclient4.retrycount and Httpclient4.idletimeout values in Jmeter.properties, and then modify the settings in the JMeter HTTP request to inherit from HttpClient4.
During the testing process, you may encounter "Java.net.URISyntaxException:Illegal character in query at index XXX", which may be due to the fact that you do not have a checkmark for the HTTP request parameters, the solution is as follows:
Web interface Performance Test summary based on HTTP request