ab is a pressure testing tool provided by apache, which is very convenient to use.
If Apache is installed, then ab is installed. If you don't want to install apache, you can install ab in the following way
# ubuntu sudo apt-get install apache2-utils # centos yum -y install httpd-tools
Before pressure testing, there are several options that need to be looked at through ab-help
Options are: -n requests Number of requests to be executed -c concurrency Concurrent number -s timeout response time
ab -n 1000 -c 100 -s 1 http://127.0.0.1:1080/event?config_name=mysql_config # A total of 100 requests were executed concurrently with a timeout of 1 s
After executing the above test commands, the following results are obtained, focusing on the following indicators:
- Failed requests: Failed requests
- Requests per second: also known as QPS, query rate per second, which is an average.
- Time per request: The time it takes to complete a request
- Transfer rate: Network transmission speed. For large file request testing, this value can easily become the bottleneck of the system. To determine whether the value is a bottleneck, we need to know the network situation between the client and the server under test, including network bandwidth and network card speed.
Server Software: Server Hostname: 127.0.0.1 Server Port: 1080 Document Path: /event?config_name=mysql_config Document Length: 0 bytes Concurrency Level: 100 Time taken for tests: 0.137 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 75000 bytes HTML transferred: 0 bytes Requests per second: 7275.11 [#/sec] (mean) Time per request: 13.745 [ms] (mean) Time per request: 0.137 [ms] (mean, across all concurrent requests) Transfer rate: 532.84 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 1.0 1 5 Processing: 1 12 5.9 11 30 Waiting: 1 11 5.9 11 29 Total: 1 13 6.1 13 30 Percentage of the requests served within a certain time (ms) 50% 13 66% 15 75% 17 80% 18 90% 22 95% 25 98% 28 99% 29 100% 30 (longest request)
wrk is a modern http performance benchmarking tool developed in c language, which is simple to use and powerful.
Installation can be downloaded from github source code compilation and installation wrk github address
wrk has few command options and is easy to use
Usage: wrk <options> <url> Options: -c, --connections <N> Established connections -d, --duration <T> Execution test time -t, --threads <N> Number of threads -s, --script <S> Use lua Script(Very powerful functions, interested in in in-depth study) -H, --header <H> For every one HTTP Request add HTTP head --latency At the end of the pressure measurement, print the delay statistics --timeout <T> timeout -v, --version Print version details Numeric arguments may include a SI unit (1k, 1M, 1G) Time arguments may include a time unit (2s, 2m, 2h)
wrk -c100 -t10 -d30s http://127.0.0.1:1080/event?config_name=mysql_config # Ten threads 100 connections manometer 30s
The results report generated by wrk is relatively concise, and the main focus is similar to ab.
- Requests/sec: QPS
- Transfer/sec: Network Transmission Speed
Running 30s test @ http://127.0.0.1:1080/event?config_name=mysql_config 10 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 21.02ms 92.04ms 1.05s 97.79% Req/Sec 1.22k 229.72 2.38k 75.47% 365483 requests in 30.07s, 26.14MB read Requests/sec: 12152.63 Transfer/sec: 0.87MB
jmeter is a GUI testing tool written by java. It has powerful functions and diverse results.
Installation can go apache jmeter download
Establish Thread Group
Thread Group can be set up after the Plan s have been set up. The way to set up Thread Group
When Plan s are selected, Edit > Add > Threads > Thread Group
Thread Group can set some parameters of threads, mainly Number of Threads(users) and Loop Count.
Listener mainly generates some result reports, which are added as follows
Edit > Add > Listener after Thread Group is selected
You can see a lot of results reports. I usually use the following results reports.
- View Results Tree
- Aggregate Report
- Graph Results
- View Results Table
View Results Tree
This report generates a request tree and clicks to view the information for each request.
This report generates aggregated statistics of requests, the main parameters being QPS, transmission speed, etc.
Powerful graphics report results
Some illustrations of graphical results
- No of Samples: Represents the number of requests sent to the server
- Deviation: Distribution of data representing the corresponding time changes of the server
- Latest Sample: Represents the time of the server's last request
- Throughtput: Here's how much data the server processes per minute
- Average: Represents the total run time divided by the number of requests sent to the server
- Median: Represents that half of the server time is below that value and the other half is above that value.
Some analysis based on graphical results
- Throughput is relatively low at the start. As the number of requests increases, the throughput increases first and then decreases.
- The deviation value is good. Keep a very stable state. If the number of deviations increases with the number of requests, the server becomes more and more unstable.