Analytical ab pressure measuring tool


Before learning ab tools, we need to understand several concepts about stress testing:

Stress testing related concepts

Throughput (Requests per second)

Concept: a quantitative description of the server's concurrent processing capacity. The unit is reqs/s, which refers to the number of requests processed per unit time under a certain number of concurrent users. The maximum number of requests that can be processed per unit time under a certain number of concurrent users is called the maximum throughput.
Calculation formula: total number of requests / time spent processing these requests, i.e
Request per second = Complete requests / Time taken for tests

The number of concurrent connections

Concept: the number of requests received by the server at a certain time is simply a session.

The number of concurrent users, Concurrency Level

Concept: pay attention to the difference between this concept and the number of concurrent connections. A user may generate multiple sessions at the same time, that is, the number of connections.

Average user request waiting time (Time per request)

Calculation formula: time spent processing all requests / (total requests / concurrent users), i.e
Time per request = Time taken for tests /( Complete requests / Concurrency Level)

Time per request: across all concurrent requests

Calculation formula: time spent processing all requests / total requests, i.e
Time taken for / testsComplete requests
As you can see, it is the reciprocal of throughput.
At the same time, it also = average user request waiting time / number of concurrent users, i.e
Time per request / Concurrency Level

ab tool introduction

ab is apache's own stress testing tool. ab is very practical. It can not only carry out website access stress test on apache servers, but also carry out stress test on or other types of servers. Such as nginx, tomcat, IIS, etc.

install

ab Command, if not installed, you can use the following command to install:
yum install httpd-tools -y

parameter list

ab: wrong number of arguments
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform   //Number of connections requested
    -c concurrency  Number of multiple requests to make at a time   //Indicates the number of concurrent
    -t timelimit    Seconds to max. to spend on benchmarking
                    This implies -n 50000
    -s timeout      Seconds to max. wait for each response
                    Default is 30 seconds
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -B address      Address to bind to when making outgoing connections
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header to use for POST/PUT data, eg.
                    'application/x-www-form-urlencoded'
                    Default is 'text/plain'
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. 'Apache=1234'. (repeatable)
    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -q              Do not show progress when doing more than 150 requests
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don't exit on socket receive errors.
    -h              Display usage information (this message)
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol
                    (SSL3, TLS1, TLS1.1, TLS1.2 or ALL)

Start test

ab -n 100 -c 10 http://www.baidu.com/more.html
 among-n Indicates the number of requests,-c Indicates the number of concurrent

  • This section shows the information of the web server. You can see that the server adopts apache, the domain name is www.baidu.com and the port is 80

  • This section is the relevant information about the requested document. The location is "/ more.html", and the size of the document is 207 bytes (this is the body length of the http response)

  • This paragraph shows several important indicators of stress testing

Detailed explanation of parameters:

Concurrency Level:      10    //Number of concurrent requests

Time taken for tests:   0.802 seconds  //Duration of the entire test

Complete requests:      100   //Number of requests completed

Failed requests:        0 //Number of failed requests

Total transferred:      35200 bytes  //Network traffic in the whole scenario

HTML transferred:       20700 bytes  //The amount of HTML content transferred throughout the scene

Requests per second:    124.71 [#/sec] (mean) / / throughput, one of the most concerned indicators, is equivalent to the number of transactions per second in LR. The mean in parentheses indicates that this is an average value

Time per request:       80.183 [ms] (mean) //The average user request waiting time, the second most concerned indicator, is equivalent to the average transaction response time in LR. The mean in parentheses indicates that this is an average value

Time per request:       8.018 [ms] (mean, across all concurrent requests) //The average request processing time of the server is the third index we are most concerned about

Transfer rate:          42.87 [Kbytes/sec] received   //The average traffic on the network per second can help eliminate the problem that the response time is prolonged due to excessive network traffic
  • This segment represents a breakdown of the time consumed on the network

  • This section shows the distribution of each request processing time. 50% of the processing time is within 273ms, 66% of the processing time is within 289ms... It is important to look at 90% of the processing time.

Questions about login

Sometimes users need to log in for stress testing. What should I do?

Refer to the following steps:

After logging in with the account and password, use the developer tool to find the Cookie value (Session ID) identifying the session and write it down

If only one Cookie is used, just type the command:

ab -n 100 -C keyļ¼¯value http://test.com/

If multiple cookies are needed, set the Header directly:

ab -n 100 -H "Cookie: Key1=Value1; Key2=Value2" http://test.com/

summary

In general, ab tool ab is small and simple, and can learn quickly. It can provide the required basic performance indicators, but it has no graphical results and cannot be monitored. Therefore, ab tools can be used as temporary emergency tasks and simple tests.

Other stress testing tools of the same type include: webch, siege and http_load, etc

Posted on Mon, 29 Nov 2021 09:58:10 -0500 by BlackenedSky