Mac uses ab command for pressure testing

1. Configure Apache in Mac

1.1 Start Apache and open the terminal

sudo apachectl -v

The Apache version is shown below

sudo apachectl start

This will start Apache.

Open the browser address bar and enter:
http: // localhost

You can see the page with the content "It works!"
Indicates normal operation.

1.2 Set Virtual Terminal

Open the Apache configuration file

sudo vi /etc/apache2/httpd.conf

Found in httpd.conf

#Include /private/etc/apache2/extra/httpd-vhosts.conf

Remove the previous "#", save and exit.

Remove this line from the # mean /extra/httpd-vhosts.confimport the virtual host configuration file.

#Include /private/etc/apache2/extra/httpd-vhosts.conf

Then restart Apache

sudo apachectl restart

Run the following command:

sudo vi /etc/apache2/extra/httpd-vhosts.conf

Open the configuration virtual host file httpd-vhost.conf, configure the virtual host. It should be noted that this file opens two virtual hosts as examples by default:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/usr/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/usr/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>

The following configuration needs to be added:

<VirtualHost *:80>
    DocumentRoot "/Library/WebServer/Documents"
    ServerName localhost
    ErrorLog "/private/var/log/apache2/localhost-error_log"
    CustomLog "/private/var/log/apache2/localhost-access_log" common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Users/snandy/work"
    ServerName mysites
    ErrorLog "/private/var/log/apache2/sites-error_log"
    CustomLog "/private/var/log/apache2/sites-access_log" common
<Directory />
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order deny,allow
            Allow from all
  </Directory>
</VirtualHost>

Save and exit

:wq
sudo apachectl restart

2. Perform pressure test after configuration is completed

ab -n 4 -c 2 https://www.baidu.com/
  • -n followed by the number of requests
  • -c is followed by the number of concurrent

2.1 Requests per second throughput

Calculation formula: total number of requests / time spent processing these requests, ie

Request per second=Complete requests/Time taken for tests

2.2 Concurrency Level Number of concurrent users

Pay attention to the difference between this concept and the number of concurrent connections. A user may have multiple sessions at the same time, that is, the number of connections. Under HTTP / 1.1, IE7 supports two concurrent connections, IE8 supports 6 concurrent connections, and FireFox3 supports 4 concurrent connections, so accordingly, our number of concurrent users must be divided by this base.

2.3 Time per request User average request waiting time

Calculation formula: time taken to process all requests / (total requests / concurrent users), namely:

Time per request=Time taken for tests/(Complete requests/Concurrency Level)

2.4 Time per request: across all concurrent requests

Calculation formula: time spent processing all requests / total requests, ie:

Time taken for/testsComplete requests

Published 420 original articles · 143 thumbs up · 890,000 views

Guess you like

Origin blog.csdn.net/jeikerxiao/article/details/102471892