{"id":243,"title":"\u7528apache\u7684ab\u5de5\u5177\u8fdb\u884c\u538b\u529b\u6d4b\u8bd5","good":0,"bad":0,"hit":2242,"created_at":"2016-10-26 15:31:35","content":"

windows\u4e0b\uff1a<\/p>

http:\/\/jingyan.baidu.com\/article\/e3c78d647a57833c4c85f502.html<\/a><\/p>

<\/p>

linux\u4e0b\uff0c\u5982\u679c\u6ca1\u6709\u88c5apche,\u5148\u8981\u88c5\u4e00\u4e0bab:<\/p>

\u6d4b\u8bd5\u5de5\u5177\u5b89\u88c5(\u4ee5centos\u7cfb\u7edf\u4e3a\u4f8b)yum -y install httpd-tools<\/p>

<\/p>

ab \u7684\u7528\u6cd5\u662f\uff1aab [options] [http:\/\/]hostname[:port]\/path<\/p>

\u4f8b\u5982\uff1aab -n 5000 -c 200 http:\/\/localhost\/index.php<\/p>

\u4e0a\u4f8b\u8868\u793a\u603b\u5171\u8bbf\u95eehttp:\/\/localhost\/index.php\u8fd9\u4e2a\u811a\u672c5000\u6b21\uff0c200\u5e76\u53d1\u540c\u65f6\u6267\u884c\u3002<\/p>

ab\u5e38\u7528\u53c2\u6570\u7684\u4ecb\u7ecd\uff1a<\/p>

-n \uff1a\u603b\u5171\u7684\u8bf7\u6c42\u6267\u884c\u6570\uff0c\u7f3a\u7701\u662f1\uff1b<\/p>

-c\uff1a \u5e76\u53d1\u6570\uff0c\u7f3a\u7701\u662f1\uff1b<\/p>

-t\uff1a\u6d4b\u8bd5\u6240\u8fdb\u884c\u7684\u603b\u65f6\u95f4\uff0c\u79d2\u4e3a\u5355\u4f4d\uff0c\u7f3a\u770150000s<\/p>

-p\uff1aPOST\u65f6\u7684\u6570\u636e\u6587\u4ef6<\/p>

-w: \u4ee5HTML\u8868\u7684\u683c\u5f0f\u8f93\u51fa\u7ed3\u679c<\/p>

<\/p>

<\/p>

\u4e0b\u9762\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u6d4b\u8bd5\uff1a<\/p>

<\/p>

[root@localhost public]# ab -n 100 -c 100 http:\/\/www.hu-rong.comab: invalid URLUsage: ab [options] [http[s]:\/\/]hostname[:port]\/pathOptions are:    -n requests     Number of requests to perform    -c concurrency  Number of multiple requests to make    -t timelimit    Seconds to max. wait for responses    -b windowsize   Size of TCP send\/receive buffer, in bytes    -p postfile     File containing data to POST. Remember also to set -T    -u putfile      File containing data to PUT. Remember also to set -T    -T content-type Content-type header for POSTing, eg.                    'application\/x-www-form-urlencoded'                    Default is 'text\/plain'    -v verbosity    How much troubleshooting info to print    -w              Print out results in HTML tables    -i              Use HEAD 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. 'Apache=1234. (repeatable)    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'                    Inserted after 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.    -X proxy:port   Proxyserver and port number to use    -V              Print version number and exit    -k              Use HTTP KeepAlive feature    -d              Do not show percentiles served table.    -S              Do not show confidence estimators and warnings.    -g filename     Output collected data to gnuplot format file.    -e filename     Output CSV file with percentages served    -r              Don't exit on socket receive errors.    -h              Display usage information (this message)    -Z ciphersuite  Specify SSL\/TLS cipher suite (See openssl ciphers)    -f protocol     Specify SSL\/TLS protocol (SSL2, SSL3, TLS1, or ALL)[root@localhost public]# ab -n 100 -c 100 http:\/\/www.hu-rong.com\/index.phpThis is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http:\/\/www.zeustech.net\/Licensed to The Apache Software Foundation, http:\/\/www.apache.org\/Benchmarking www.hu-rong.com (be patient).....doneServer Software:        nginxServer Hostname:        www.hu-rong.comServer Port:            80Document Path:          \/index.phpDocument Length:        21966 bytesConcurrency Level:      100Time taken for tests:   7.392 secondsComplete requests:      100Failed requests:        0Write errors:           0Total transferred:      2357528 bytesHTML transferred:       2320439 bytesRequests per second:    13.53 [#\/sec] (mean)Time per request:       7391.820 [ms] (mean)Time per request:       73.918 [ms] (mean, across all concurrent requests)Transfer rate:          311.46 [Kbytes\/sec] receivedConnection Times (ms)              min  mean[+\/-sd] median   maxConnect:       11  749 1248.5     96    3037Processing:    44 2361 1763.3   2064    7151Waiting:       29  630 595.0    415    3061Total:        122 3110 2002.9   3629    7234Percentage of the requests served within a certain time (ms)  50%   3629  66%   4245  75%   4644  80%   4947  90%   5532  95%   6486  98%   6776  99%   7234 100%   7234 (longest request)[root@localhost public]# <\/p>"}