Apache service ab stress test

Before ab stress test, explain the following concepts:

Requests per second

The quantitative description of the concurrent processing capability of the server, in reqs/s, refers to the number of requests processed in unit time under the number of concurrent users. The maximum number of requests that can be processed per unit time under the number of concurrent users is called the maximum throughput.

Calculation formula:

Total requests / time taken to process these requests, i.e
Request per second = Complete requests / Time taken for tests

The number of concurrent connections

The number of requests accepted by the server at a certain time is simply a session.

The number of concurrent users (Concurrency Level)

Pay attention to the difference between the concept and the number of concurrent connections. A user may have multiple sessions at the same time, that is, the number of connections.

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 request waiting time / number of concurrent users, i.e
Time per request / Concurrency Level

ab pressure test tool

  • Apache has its own stress testing tool ab, which is easy to use and can simulate various conditions to send test requests to Web servers;

  • ab tool can directly initiate test request in the local area of Web server, which is very important to understand the processing performance of the server, because it does not include the network transmission time of data and the local calculation time of user PC, so that the performance of Web server can be judged by observing various time indexes, so as to optimize and adjust the parameters.

  • In the process of performance adjustment and optimization, ab pressure test tool can be used to test the optimization effect

Using ab stress testing tool to optimize the process

  • Before optimization, ab tool was used for pressure test;

  • After optimization, restart the service, and then use ab for stress test;

  • Compare the results of the two tests to see whether the optimization effect is obvious;

  • In order to evaluate the performance of web services more objectively, we usually need to test many times before and after optimization, and take the average value of test results for comparison.

Use of ab tool

Command format:

ab [options] website

Common parameters:

-n: total number of requests executed
 -c: concurrent number
 -t: total time of test execution, in seconds
 -v: how much troubleshooting information to print
 -V: display version number and exit

To manually compile and install the Apache service:

(1) install the DNS service package bind.

[root@localhost ~]# yum install bind -y
......//Omit installation process
[root@localhost ~]#

(2) modify the main configuration file of DNS service.

[root@localhost ~]# vim /etc/named.conf

options {
        listen-on port 53 { any; };                   //127.0.0.1 to any
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        recursing-file  "/var/named/data/named.recursing";
        secroots-file   "/var/named/data/named.secroots";
        allow-query     { any; };               //Change localhost to any

(3) modify the zone configuration file of DNS service.

[root@localhost ~]# vim /etc/named.rfc1912.zones

zone "abc.com" IN {                                 //Add a domain name information
        type master;
        file "abc.com.zone";
        allow-update { none; };
};

(4) check the IP address.

[root@localhost named]# ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.52.133  netmask 255.255.255.0  broadcast 192.168.52.255
        inet6 fe80::3e1d:31ba:f66a:6f80  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:27:1c:3f  txqueuelen 1000  (Ethernet)
        RX packets 14532  bytes 20210558 (19.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6054  bytes 399142 (389.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

(5) reserve the permission to copy a zone data configuration file of DNS service and modify it.

[root@localhost ~]# cd /var/named / / / switch directories
[root@localhost named]# ls / / view
data  dynamic  named.ca  named.empty  named.localhost  named.loopback  slaves
[root@localhost named]# cp -p named.localhost abc.com.zone / / copy
[root@localhost named]# vim abc.com.zone 

$TTL 1D
@       IN SOA  @ rname.invalid. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       127.0.0.1
www IN  A       192.168.52.133             //Add domain name resolution for IPv4

(6) start the named service.

[root@localhost named]# systemctl start named / / start the service
[root@localhost named]# systemctl stop firewalld.service / / turn off the firewall
[root@localhost named]# setenforce 0 / / turn off enhanced security
[root@localhost named]# 

(7) share the toolkit we need on the host.

(8) mount the toolkit to Linux system through Samba service.

[root@localhost ~]# smbclient -L //192.168.100.50 / / view share
Enter SAMBA\root's password:      //Anonymous sharing, no password, enter directly
OS=[Windows 10 Enterprise LTSC 2019 17763] Server=[Windows 10 Enterprise LTSC 2019 6.3]

    Sharename       Type      Comment
    ---------       ----      -------
    IPC$            IPC       Long-range IPC
    share           Disk      
    tools           Disk      
    Users           Disk      
Connection to 192.168.100.50 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
NetBIOS over TCP disabled -- no workgroup available
[root@localhost ~]# mkdir /mnt/tools / / create the mount directory
[root@localhost ~]# mount.cifs //192.168.100.50/tools /mnt/tools / / Mount
Password for root@//192.168.100.50/tools:  
[root@localhost ~]# cd /mnt/tools / / / enter the mount directory
[root@localhost tools]# ls / / view
awstats-7.6.tar.gz                extundelete-0.2.4.tar.bz2  forbid.png                 jdk-8u191-windows-x64.zip  LAMP-C7
cronolog-1.6.2-14.el7.x86_64.rpm  fiddler.exe                intellijideahahau2018.rar  john-1.8.0.tar.gz          picture.jpg
[root@localhost tools]# 

(9) extract the compressed package of the source code compilation and installation of Apache service to the "/ opt /" directory.

[root@localhost tools]# cd LAMP-C7 / / / switch directories
[root@localhost LAMP-C7]# ls
apr-1.6.2.tar.gz       Discuz_X2.5_SC_UTF8.zip  LAMP-php5.6.txt      php-5.6.11.tar.bz2
apr-util-1.6.0.tar.gz  httpd-2.4.29.tar.bz2     mysql-5.6.26.tar.gz
[root@localhost LAMP-C7]# tar jxvf httpd-2.4.29.tar.bz2 -C /opt / / / unzip
......//Omit decompression details
[root@localhost LAMP-C7]# tar zxvf apr-1.6.2.tar.gz -C /opt / / / unzip
......//Omit decompression details
[root@localhost LAMP-C7]# tar zxvf apr-util-1.6.0.tar.gz -C /opt / / / unzip
......//Omit decompression details

(10) enter the "/ opt /" directory, move the two apr packages to the "httpd-2.4.29/srclib /" directory, and rename them.

[root@localhost LAMP-C7]# cd /opt/    
[root@localhost opt]# ls
apr-1.6.2  apr-util-1.6.0  httpd-2.4.29  rh
[root@localhost opt]# mv apr-1.6.2/ httpd-2.4.29/srclib/apr
[root@localhost opt]# mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util

(11) enter the "httpd-2.4.29 /" directory, and then install the required environment package for compilation.

[root@localhost opt]# ls
httpd-2.4.29  rh
[root@localhost opt]# cd httpd-2.4.29/
[root@localhost httpd-2.4.29]# ls
ABOUT_APACHE     ap.d          CHANGES         docs         httpd.spec      libhttpd.dep  Makefile.win   README            srclib
acinclude.m4     build         CMakeLists.txt  emacs-style  include         libhttpd.dsp  modules        README.cmake      support
Apache-apr2.dsw  BuildAll.dsp  config.layout   httpd.dep    INSTALL         libhttpd.mak  NOTICE         README.platforms  test
Apache.dsw       BuildBin.dsp  configure       httpd.dsp    InstallBin.dsp  LICENSE       NWGNUmakefile  ROADMAP           VERSIONING
apache_probes.d  buildconf     configure.in    httpd.mak    LAYOUT          Makefile.in   os             server
[root@localhost httpd-2.4.29]# 
[root@localhost httpd-2.4.29]# yum -y install \
> gcc \
> gcc-c++ \
> make \
> pcre \
> pcre-devel \
> expat-devel \
> zlib-devel \
> perl
......//Omit installation process

(12) configure the Apache server.

[root@localhost httpd-2.4.29]# ./configure \
> --prefix=/usr/local/httpd \    //Installation path
> --enable-so \     //Enable dynamic load module support
> --enable-rewrite \     //Enable Web address rewriting
> --enable-charset-lite \    //Enable character set support
> --enable-cgi    //Enable CGI scripting support

(13) compile and install Apache service.

[root@localhost httpd-2.4.29]# make && make install
......//Omit compilation and installation
[root@localhost httpd-2.4.29]#

(14) modify the Apache service configuration file

[root@localhost httpd-2.4.29]# ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf / / create a soft link for easy use
[root@localhost httpd-2.4.29]# 

Listen 192.168.50.133:80    //Enable IPv4 monitoring
#Listen 80 / / Note IPv6 listening
#
ServerName www.abc.com:80      //Set domain name

ab pressure test

[root@localhost named]# ab -n 3000 -c 1000 www.abc.com/index.html
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.abc.com (be patient)
Completed 300 requests
Completed 600 requests
Completed 900 requests
Completed 1200 requests
Completed 1500 requests
Completed 1800 requests
Completed 2100 requests
Completed 2400 requests
Completed 2700 requests
Completed 3000 requests
Finished 3000 requests

Server Software:        Apache/2.4.29            //Header information of http response data
Server Hostname:        www.abc.com         //Host name in the requested url
Server Port:            80                                   //Listening port of web server software

Document Path:          /index.html              //The absolute path of the requested url root
Document Length:        45 bytes                //Body length of http response data

Concurrency Level:      1000                     //Number of concurrent users
Time taken for tests:   21.061 seconds    //The total time taken for all these requests to be processed
Complete requests:      3000         //Indicates the total number of requests
Failed requests:        220             //Total requests failed
   (Connect: 0, Receive: 0, Length: 220, Exceptions: 0)
Total transferred:      810356 bytes       //Total response data length requested
HTML transferred:       126180 bytes
Requests per second:    142.44 [#/sec] (mean) / / throughput of the server, the total number of requests processed per second
Time per request:       7020.414 [ms] (mean)    //Average user request wait time
Time per request:       7.020 [ms] (mean, across all concurrent requests)    //Average actual run time per request
Transfer rate:          37.57 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    9  14.5      4      62
Processing:     9 1389 5135.1     27   21027
Waiting:        0   27  34.4     22     234
Total:         13 1398 5132.8     33   21027

Percentage of the requests served within a certain time (ms)   //Describe the distribution of processing time for each request.
  50%     33
  66%     37
  75%     42
  80%     55
  90%     95
  95%  21020
  98%  21027
  99%  21027
 100%  21027 (longest request)
[root@localhost named]#
parameter describe
Server Software Header information of http response data
Server Hostname Host name in the requested url
Server Port Listening port of web server software
Document Path The absolute path of the requested url root
Document Length Body length of http response data
Concurrency Level Number of concurrent users
Time taken for tests The total time taken for all these requests to be processed
Complete requests Indicates the total number of requests
Failed requests Total requests failed
Total transferred Total response data length requested
Requests per second Throughput of the server, number of requests processed per second
Time per request Average user request wait time
Time per request Average actual run time per request
Percentage of the requests served within a certain time (ms) Describe the distribution of processing time for each request

Keywords: Linux Apache Web Server DNS vim

Added by jakebur01 on Tue, 05 Nov 2019 19:34:28 +0200