Description: With the benefits of AB, in the case of multi-concurrency, do not write your own threading simulation.
Website:
http://httpd.apache.org/(Apache server)
http://httpd.apache.org/docs/2.0/programs/(Apache tools documentation Daquan)
http://httpd.apache.org/docs/2.0/programs/ab.html (Documentation Tutorial)
http://httpd.apache.org/docs/current/programs/ab.html (Documentation Tutorial)
Tutorial:
It's very simple to stress test Apache and its web programs, and we don't have to download any additional test tools to install, because Apache HTTP Server has prepared a stress test tool for--ab.
AB, Apache Benchmark, can be found in Apache's installation directory as long as we have Apache installed. Its residential address is Apache安装目录/bin/ab
. Now, let's take a look at how to use Ab.exe for stress testing.
Before using it, let's learn AB's usage first. Apache安装目录/bin/
. Then type the help command ab -help
(or ab /?
, ab -h
) and we can see the following usage interface.
Introduction to AB Usage
As you can tell by the above usage, the use of AB is to enter the following command:
AB [optional parameter options] URL required for stress testing
In addition, we will learn more about the role of each parameter option based on the usage interface described above.
- N: Requests, which specifies the total number of executions for the stress test. -C: Concurrency, which specifies the number of concurrency for a stress test. -T: TimeLimit, the maximum time to wait for a response(Unit: seconds). -B: Windowsize,tcp send/received buffer size (in bytes). -P: Postfile, the file to be uploaded when the POST request is sent, and the-T parameter must also be set. -U: putfile, the file to be uploaded when the put request is sent, and the-T parameter must also be set. -T: content-typeTo set the Content-type request header information, for example: application/x-www-form-urlencoded, the default value is text/Plain. -V: verbosity, which specifies the level of redundancy for printing help information. -W: Prints the results in an HTML table format. -I: Use head request instead of GET request. -X: Inserts a string as a property of the table label. -Y: Inserts a string as a property of the TR label. -Z: Inserts a string as a property of the TD label. -C: Add cookie information, for example:"Apache=1234" (You can repeat this parameter option to add multiple). -H: Add any request headers, for example:"Accept-encoding:gzip", the request header will be added after the existing multiple request headers (you can repeat the parameter option to add multiple). -A: Add a basic network authentication information, separated by a colon between the user name and the password. -P: Add a basic proxy authentication message, separated by a colon between the user name and password. -X: Specify the proxy server and port number to use, for example:"126.10.10.3:88". -V: Prints the version number and exits. -K: Use the KeepAlive attribute of HTTP. -K: Use the KeepAlive attribute of HTTP. -D: Do not display percentages. -S: no estimate and warning messages are displayed. -G: Outputs the result information to a file in the gnuplot format. -E: Outputs The result information to a file in CSV format. -R: Specifies that the program is not exited when an error message is received. -H: Displaying usage information is actually ab-help.
Although AB can be configured with more parameter options, in general we only need to use ab -n 数字 -c 数字 url路径
the shape of the command. For example, we stress-test a page that is located on a local Apache server and has a URL of localhost/index.php. The total number of tests was 1000, and the number of concurrent sessions was 100 (equivalent to 100 users accessing them concurrently, with a total of 1000 visits). We enter the ab -n 1000 -c 100 localhost/index.php
command and print the results as follows:
ab-n 1000-c localhost/index. php This is Apachebench, Version 2.3 < $Revision: 655654 $>Copyright1996 Adam Twiss, Zeus technology Ltd, Http://www.zeustech.Net/Licensed to the Apache software Foundation, http://www.apache.org/Benchmarking localhost(Be patient)completed100requestscompleted200requestscompleted300requestscompleted400requestscompleted500requestscompleted600requestscompleted700requestscompleted800requestscompleted900requestscompleted1000requestsfinished1000Requestsserver Software:apache/2.2.25 (Server Software name and version information)Server hostname:localhost(Server host name)Server Port:80 (server port)DocumentPath:/index.php (URL path for testing)Document Length:Bytes (the document size returned by the URL for testing)Concurrency Level:100 (concurrent number) TimeTaken fortests:0.247 seconds (total time spent on stress test)Complete Requests:1000 (total number of stress tests)Failed Requests:0 (number of failed requests)Write Errors:0 (Number of network connection write errors)Total Transferred:198000 bytes (total amount of data transferred)HTML Transferred:10000 bytes (total data volume for HTML documents)Requests per second:4048.34 [#/sec] (mean) (average number of requests per second) TimePer request:24.701 [MS] (mean) (the average time that all concurrent users (here is 100) are requested) TimePer request:0.247 [MS] (mean, across all concurrent requests) (average time for a single user request)Transfer Rate:782.78 [Kbytes/sec] Received (transfer rate, Unit: KB/S)Connection Times(MS)min mean[+/-SD] Median maxconnect:0 0 0.3) 0 1Processing:6 23 4.2) 24 30Waiting:5 20 5.3) 21 29Total:6 23 4.2) 24 30Percentage of the requests served within a certain Time(ms) 50% 66% 75% 80% 90% 95% 98% (99%) 100% Request
In the above test, the total number of stress tests we set and the number of concurrency did not make the server feel any "pressure", now we look at a "pressure Alexander" execution command ab -n 100000 -c 1000 localhost/index.php
:, this time Apache directly strike-denied access:
ab-n 100000-c localhost/index. phpThis is apachebench, Version 2.3 < $Revision: 655654 $>1996 Adam Twiss, Zeus technolog Y Ltd, Http://www.zeustech. Net/Licensed to the Apache software Foundation, http://www.apache.org/(Be patient) failuresapr_socket_connect(): Unable to connect because the target computer was actively rejected. (730061)
Note: In the above stress test, Apache is using the default configuration and has not been processed by any optimization measures. In fact, after configuration optimization, Apache server can hold up to 1000 concurrency as long as the server hardware is sufficient.
Reference:
Http://www.365mini.com/page/apache-benchmark.htm (the above content is transferred from this article)
Http://www.php.cn/php-weizijiaocheng-371644.html
Http://www.jianshu.com/p/1f3acc45ca89
Http://www.jb51.net/article/59469.htm
http://blog.51cto.com/510512/740219
http://blog.csdn.net/blueheart20/article/details/52170790
http://xuezaijiongtu.blog.163.com/blog/static/197576271201251101527325/
Http://www.jianshu.com/p/43d04d8baaf7
Http://www.jb51.net/article/56644.htm
Apache Pressure (concurrency) test Tool AB Tutorial Collection