Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and use of stress testing tool ab under Apache

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on the installation and use of ab, a stress testing tool under Apache. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "the installation and use of ab, a stress testing tool under Apache".

At present, the most common reading guide performance testing tools are as follows: ab, http_load, webbench, siege.

Ab is a stress testing tool that comes with apache. Ab is very practical. It can be used not only for website access stress testing of apache servers, but also for other types of servers. Such as nginx, tomcat, IIS and so on.

I. the principle of ab

Ab is an abbreviation for the apachebench command.

How ab works: the ab command creates multiple concurrent access threads to simulate multiple visitors accessing a URL address at the same time. Its testing goal is based on URL, so it can be used not only to test the load pressure of apache, but also to test the pressure of other Web servers such as nginx, lighthttp, tomcat, IIS and so on.

The ab command requires very little of the computer that issues the load, and it takes up neither a very high CPU nor a lot of memory. But it will cause a huge load on the target server, and the principle is similar to CC attacks. You should also pay attention to testing and using it yourself, otherwise there will be too much load at a time. It may cause the target server to run out of resources, and even lead to a crash in serious cases.

II. Installation of ab

The installation of ab is very simple, and it is even easier if you install apache in source code. After the apache installation, the ab command is stored in the bin directory of the apache installation directory. As follows:

/ usr/local/apache2/bin

If apache is installed through yum's RPM package, the ab command is stored in the / usr/bin directory by default. As follows:

Which ab

Note: if you don't want to install apache but want to use the ab command, you can install apache's toolkit httpd-tools directly. As follows:

Yum-y install httpd-tools

To see if ab is installed successfully, you can change to the above directory and use the ab-V command to test. As follows:

Ab-V

If the ab installation is successful, the ab-V command displays the preferred version of ab, as shown above.

Note that the above is installed on the linux platform. If it is on the windows platform, we can also download the corresponding apache version for installation.

3. Description of ab parameters

About the use of the ab command, we can view it through the help command. As follows:

Ab-help

These parameters are described below.

-n the number of requests executed in the test session. By default, only one request is executed.

-c the number of requests generated at a time. The default is one at a time.

The maximum number of seconds performed by the-t test. Its internal implied value is-n 50000, which limits the testing of the server to a fixed total time. By default, there is no time limit.

-p contains files that require POST data.

-P provides BASIC authentication trust to a transit agent. The user name and password are separated by a: and sent in base64 code. This string is sent regardless of whether the server needs it (that is, whether the 401 authentication requirement code is sent).

-Content-type header information used by T POST data.

-v sets the detail level of the display information-4 or greater displays header information, 3 or greater can display response code (404200, etc.), 2 or greater can display warnings and other information.

-V displays the version number and exits.

-w outputs the results in the format of HTML table. By default, it is a table with two columns wide on a white background.

-I execute the HEAD request instead of the GET.

-x settin

The string for the property.

-X uses a proxy server for requests.

-y settin

The string for the property.

-z settin

The string for the property.

-C appends a Cookie: line to the request. Its typical form is a parameter pair of name=value, which can be repeated.

-H appends additional header information to the request. The typical form of this parameter is a valid header line that contains pairs of fields and values separated by colons (for example, "Accept-Encoding:zip/zop;8bit").

-A provides BASIC authentication trust to the server. The user name and password are separated by a: and sent in base64 code. This string is sent regardless of whether the server needs it (that is, whether the 401 authentication requirement code is sent).

-h shows how to use it.

-d does not display the message "percentage served within XX [ms] table" (support for previous versions).

-e produces a comma-separated (CSV) file that contains the appropriate percentage of time (in subtleties) required to process each appropriate percentage of requests (from 1% to 100%). Because this format is "binary", it is more useful than the 'gnuplot' format.

-g writes all test results to a 'gnuplot' or TSV (delimited by Tab) file. This file can be easily imported into Gnuplot,IDL,Mathematica,Igor or even Excel. One of the first behavior titles.

-I execute the HEAD request instead of the GET.

-k enables the HTTP KeepAlive feature, that is, to execute multiple requests in a HTTP session. The KeepAlive feature is not enabled by default.

-Q if the number of requests processed is greater than 150, every time about 10 or 100 requests are processed, a progress count will be output in stderr. This-Q flag suppresses this information.

Fourth, ab performance index

There are several metrics that are important during performance testing:

1. Throughput (Requests per second)

A quantitative description of the server's concurrent processing capacity, in 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 maximum throughput.

A, throughput is related to the number of concurrent users

B. Under different concurrent users, the throughput is generally different.

Formula: total number of requests / time it takes to process these requests, that is

Request per second=Complete requests/Time taken for tests

It must be noted that this value represents the overall performance of the current machine, and the higher the value, the better.

2. Concurrent connections (The number of concurrent connections)

The number of concurrent connections refers to the number of requests accepted by the server at a certain time, in short, a session.

3. Number of concurrent users (Concurrency Level)

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 six concurrent connections, and FireFox3 supports four concurrent connections, so accordingly, our number of concurrent users has to be divided by this cardinality.

4. APCge request waiting time (Time per request)

Calculation formula: the time it takes to process all requests / (total requests / concurrent users), that is:

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

5. APCge request waiting time on the server (Time per request:across all concurrent requests)

Calculation formula: the time / total number of requests taken to process all requests completed, that is:

Time taken for/testsComplete requests

As you can see, it is the reciprocal of throughput.

At the same time, it is also equal to the average request waiting time of users / the number of concurrent users, that is

Time per request/Concurrency Level

V. actual use of ab

Ab has a lot of command parameters, and we often use the-c and-n parameters.

[root@localhost] # ab-c 10-n 1000 http://192.168.0.220:9088/

If you use a Cookie, just type the command: ab-n 100-C key=value http://test.com/

If you need more than one Cookie, set Header:ab-n 100-H "Cookie: Key1=Value1; Key2=Value2" http://test.com/ directly.

The throughput rate tested by apache is: Requests per second [# / sec] (mean).

Server Software represents the name of the Web server software being tested.

Server Hostname represents the requested URL hostname.

Server Port represents the listening port of the Web server software being tested.

Document Path represents the root absolute path in the requested URL, and we can generally know the type of the request by the suffix name of the file.

Document Length represents the body length of the HTTP response data.

Concurrency Level represents the number of concurrent users, which is one of the parameters we set.

Time taken for tests indicates the total time it takes for all these requests to be processed.

Complete requests represents the total number of requests, which is one of the parameters we set.

Failed requests indicates the number of failed requests. In this case, failure means that an exception occurs when a request connects to the server, sends data, and times out after no response. If the header information of the received HTTP response data contains a status code other than 2XX, another statistical item called "Non-2xx responses" is displayed in the test results, which is used to count this part of the requests, which are not counted as failed requests.

Total transferred represents the sum of the response data lengths for all requests, including the header information and body data length of each HTTP response data. Note that the length of the HTTP request data is not included here, but only the total length of the application layer data that the web server flows to the user PC.

HTML transferred represents the sum of the body data in the response data of all requests, that is, minus the length of the header information in the HTTP response data in the Total transferred.

Requests per second throughput, calculation formula:

Complete requests/Time taken for tests

APCge request waiting time for Time per request users. Calculation formula:

Time token for tests/ (Complete requests/Concurrency Level)

Average request waiting time for Time per requet (across all concurrent request) server, calculated by formula:

Time taken for tests/Complete requests

Which happens to be the inversion of throughput. It can also be counted like this: Time per request/Concurrency Level.

Transfer rate represents the length of data obtained from the server by these requests per unit time, and calculates the formula:

Total trnasferred/ Time taken for tests

This statistics is a good indication of the demand for broadband for export when the server's processing capacity reaches its limit.

Percentage of requests served within a certain time (ms) is used to describe the distribution of processing time of each request. For example, in the above test, 80% of the request processing time does not exceed 6ms. This processing time refers to the previous Time per request, that is, the average processing time of each request for a single user.

At this point, I believe you have a deeper understanding of "the installation and use of the stress testing tool ab under Apache". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report