Use the Apache AB tool to perform a simple stress test on the Apache server _linux

Source: Internet
Author: User
Tags server port

1. Install AB command

sudo apt-get install apache2-utils 

2.ab Command parameter description

Usage:ab [Options] [http[s]://]hostname[:p Ort]/path
Options are:

Total requests-  
N requests number of requests to perform 
 
//simultaneous concurrent requests total number of requests (n) = number of concurrent (c)-C  
concurrency number of Multiple requests to make 

-N requests number of requests to perform
The number of requests that were executed in the test session (the total number of times the page was visited for this test). By default, only one request is executed.
-c concurrency number of multiple requests to make
The number of requests (concurrent numbers) produced at a time. The default is one at a time.
-T TimeLimit Seconds to Max. Wait for responses
The maximum number of seconds that the test was made. Its intrinsic implied value is-n 50000. It can limit the testing of the server to a fixed total time. By default, there is no time limit.
-P postfile File containing data to POST
A file that contains the data that needs to be post, and the file format is "p1=1&p2=2". The use method is-P 111.txt. (with-T)
-T Content-type content-type header for POSTing
The Content-type header information used by the post data, such as-T "application/x-www-form-urlencoded". (with-P)
-V verbosity how much troubleshooting info to print
Set the level of detail for display information –4 or larger values display header information, 3 or greater values can display response codes (404, 200, etc.), and 2 or greater values can display warnings and other information. -V Displays the version number and exits.
-W Print out results in HTML tables
Output the results in an HTML table format. By default, it is a table with two columns of white background width.
-I use head instead of
Executes the head request instead of get.
-X attributes String to insert as table attributes
-Y attributes String to insert as TR attributes
-Z attributes String to insert as TD or TH attributes
-C attribute Add cookie, eg. -C "C1=1234,c2=2,c3=3″ (repeatable)
-C Cookie-name=value attach a cookie to the request: line. The typical form is a parameter pair of Name=value. This parameter can be repeated, separated by commas.
Hint: can pass the Jsessionid parameter through the session realization principle, realizes maintains the conversation the function, like
-C "c1=1234,c2=2,c3=3, Jsessionid=ff056cd16da9d71cb131c1d56f0319f8″.
-H attribute Add arbitrary header line, eg. ' Accept-encoding:gzip ' Inserted after the all normal header lines. (repeatable)
-A attribute Add Basic WWW authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy authentication, the attributes
are a colon separated username and password.
-P Proxy-auth-username:password provides basic authentication trust to a relay agent. The username and password are separated by one: and sent in the form of a base64 encoding. This string is sent regardless of whether the server needs to (that is, whether the 401 authentication requirement code is sent).
-X Proxy:port ProxyServer and port number to use
-V Print version number and exit
-K Use HTTP KeepAlive feature
-D don't show percentiles served table.
-S don't show confidence estimators and warnings.
-G filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-H Display Usage information (this message)
-attributes the string that sets the property. There are a variety of statically declared fixed-length buffers in the flaw program. In addition, parsing of command-line arguments, server response headers, and other external input is simple, which can have undesirable consequences. It does not realize http/1.x completely; Only some ' expected ' response formats are accepted. The frequent use of STRSTR (3) can cause performance problems, that is, you may be testing AB rather than server performance.

3. Run

 

100 requests were made to the http://www.jb51.net/, 10 concurrent requests for stress test results.

Server software:lighttpd/1.4.20 Server Hostname:www.jb51.net server port:80 Document Path:/Document LENGTH:20 Bytes concurrency level:10//Overall test duration time taken the for tests:3.303 seconds//completed requests Complete requests:1  
Failed requests:0 Write errors:0 total transferred:235200 bytes HTML transferred:209500 bytes//average processing of 30 requests per second Requests per second:30.27 [#/sec] (mean)//The average processing time for each request is 330 milliseconds: 10 concurrent requests will be treated as a whole at once./request:330.335 [MS] (M  EAN)//Average concurrent request processing time is 33 Ms request:33.034 [MS] (mean, across all concurrent requests) Transfer rate:69.53 [Kbytes/sec] Received Connection times (ms) min MEAN[+/-SD] median max connect:51 170 35.9 178 230 processing:60 153 64.5 121 263 waiting:55 148 64.4 # 258 total:235 322 59.9 299 437 percentage of the requests served within a 
Certain time (MS)////50% of these 100 requests completed in 299 milliseconds 50% 299//100 of the 66% requests were completed in 312 milliseconds 66% 312 75% 383 80% 412 90% 95% 432 98% 436 99% 437 100% 437 (longest request) 

 

PS: How to view the current number of Apache connections
viewed the number of connections and the current number of connections

Netstat-ant | grep $IP: 80 | Wc-l  
netstat-ant | grep $ip: | grep EST | wc-l  

View IP access times

Netstat-nat|grep ":" |awk ' {print $} ' |awk-f: ' {print $} ' | Sort| Uniq-c|sort-n 

Linux command:

Netstat-n | awk '/^tcp/{++s[$NF]} end {to (a in S) print A, S[a]} ' 
Watch ' netstat-n | awk '/^tcp/{++s[\ $NF]} end {to (a in S) print A, S[a]} ' " 

Return sample results:

Last_ack 5
SYN_RECV
established 1597
fin_wait1 Wuyi
fin_wait2 504
time_wait 1057

Description:
Syn_recv represents the number of requests waiting to be processed;
established represents normal data transfer status;
Time_wait indicates the number of requests that have been processed, waiting for the timeout to end, and
Fin_wait1 Represents a server-side initiative to shut down a TCP connection;
Fin_wait2 indicates that the client is disconnected;
Last_ack shutting down a TCP connection needs to be shut down in two directions, both by sending a FIN to indicate the closure of the single direction data. When the communication both sides send the last fin, the sender is in Last_ack state at this time, when the sender received the confirmation of the other (Fin ack confirmation) before the actual shutdown of the entire TCP connection;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.