Home  >  Article  >  Backend Development  >  Detailed explanation of using Apache's ab tool example

Detailed explanation of using Apache's ab tool example

零下一度
零下一度Original
2017-06-30 15:59:202353browse

ab command principle
Apache's ab command simulates multi-threaded concurrent requests to test server load pressure. It can also test the pressure of other web servers such as nginx, lighthttp, IIS, etc.
The ab tool that comes with Apache (the PHP environment used is the WAMP integrated environment, the ab tool is located in D:\wamp\bin\apache\Apache2.2.21\bin) is very easy to use. The ab command has very low requirements on the computer that issues the load. It will not occupy a lot of CPU or memory, but it will cause a huge load to the target server. Therefore, it is a necessary medicine for some DDOS attacks. Suitable for all. You must also be careful when using it yourself. Otherwise, too much load is applied at once, causing the target server to crash due to running out of memory and having to hard restart, which is not worth the loss.

In the case of insufficient bandwidth, it is best to test on the local machine. It is recommended to use another or multiple servers on the intranet to test through the intranet. The data obtained in this way will be much more accurate. . Remote stress testing of web servers often yields unsatisfactory results (due to excessive network latency or insufficient bandwidth)

Download and install:
;O=A
Find httpd- 2.2.21-win32-x86-no_ssl.msi

Parameter documentation:

Run:
Under Windows system, open the cmd command line window and navigate to the bin directory of the apache installation directory
cd C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin

Type the command:
ab -n 800 -c 800 http://192.168.0.10/
(-n issues 800 requests, -c simulates 800 concurrency, equivalent to 800 people accessing at the same time, followed by the test url)

ab -t 60 -c 100 http://192.168.0.10/
Send requests within 60 seconds, 100 requests at a time.

//If you need to bring parameters in the url, do this
ab -t 60 -c 100 -T "text/plain" -p p.txt http://192.168.0.10/hello. html
p.txt is in the same directory as ab.exe
p.txt. You can write parameters in it, such as p=wdp&fq=78

Detailed explanation of using Apaches ab tool example

Detailed explanation of using Apaches ab tool example-曾祥展
Explanation of result parameters:
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
Licenseed to The Apache Software Foundation,

Benchmarking 192.168.0.10 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Finished 800 requests

Server Software: Microsoft-HTTPAPI/2.0 Represents the web server being tested Software name
Server Hostname: 192.168.0.10 Represents the requested URL host name
Server Port: 80 Represents the tested Web server software Listening port

Document Path:                                                                                                                                                                                                                                    Root absolute path. Through the suffix name of this file, we can generally understand the type of the request
DOCUMENT LENGTH: 315 bytes.

Concurrency Level: 800 represents the number of concurrent users. This is one of the parameters we set. ## FAILED Requests: 0 Failure Requests
Write Errs: 0
Non-2xx Responses: 800
Total Transferred: 393600 bytes Total Transmission
HTML Transferred: 252000 bytes HTML content Transmission volume
Requests per second: 875.22 [#/sec] (mean) Throughput - number of requests per second
Time per request: 914.052 [ms] (mean) The time it takes for the server to receive a request and respond to the page
Time per request: 1.143 [ms] (mean, across all concurrent requests) The average time consumed by each concurrent request
Transfer rate: 420.52 [Kbytes/sec] received The average traffic on the network per second, which can help to rule out whether there is The problem of prolonged response time caused by excessive network traffic


Breakdown of time spent on the network:

Connection Times (ms) min mean[+/-sd] median max

Connect: 0 1 0.5 1 3
Processing: 245 534 125.2 570 682
Waiting: 11 386 189.1 409 669
Total: 246 535 125.0 571 684

Response status of all requests in the entire scenario. In the scenario, each request has a response time
50% of the user response time is less than 571 milliseconds

80% of the user response time is less than 652 milliseconds

The maximum response time is less than 684 milliseconds
Percentage of the requests served within a certain time (ms)
50% 571
66% 627
75% 646
80% 652
90% 666
95% 677
98% 681
99% 682
100% 684 (longest request)

This part of the data is used to describe the distribution of each request processing time. For example, in the above test, 80% of the request processing time None 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.

The above is the detailed content of Detailed explanation of using Apache's ab tool example. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn