{"id":1005,"date":"2009-11-29T19:26:00","date_gmt":"2009-11-29T11:26:00","guid":{"rendered":"\/?p=1005"},"modified":"2009-11-29T19:26:00","modified_gmt":"2009-11-29T19:26:00","slug":"1005","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/architecture\/1005.html","title":{"rendered":"Web\u670d\u52a1\u5668\u6027\u80fd\/\u538b\u529b\u6d4b\u8bd5\u5de5\u5177http_load\u3001webbench\u3001ab\u3001Siege"},"content":{"rendered":"

\u4e00\u3001http_load<\/strong><\/p>\n

\u7a0b\u5e8f\u975e\u5e38\u5c0f\uff0c\u89e3\u538b\u540e\u4e5f\u4e0d\u5230100K<\/p>\n

http_load\u4ee5\u5e76\u884c\u590d\u7528\u7684\u65b9\u5f0f\u8fd0\u884c\uff0c\u7528\u4ee5\u6d4b\u8bd5web\u670d\u52a1\u5668\u7684\u541e\u5410\u91cf\u4e0e\u8d1f\u8f7d\u3002\u4f46\u662f\u5b83\u4e0d\u540c\u4e8e\u5927\u591a\u6570\u538b\u529b\u6d4b\u8bd5\u5de5<\/p>\n

\u5177\uff0c\u5b83\u53ef\u4ee5\u4ee5\u4e00\u4e2a\u5355\u4e00\u7684\u8fdb\u7a0b\u8fd0\u884c\uff0c\u4e00\u822c\u4e0d\u4f1a\u628a\u5ba2\u6237\u673a\u641e\u6b7b\u3002\u8fd8\u53ef\u4ee5\u6d4b\u8bd5HTTPS\u7c7b\u7684\u7f51\u7ad9\u8bf7\u6c42\u3002<\/p>\n

\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/soft.vpser.net\/test\/http_load\/http_load-12mar2006.tar.gz<\/a>
\u5b89\u88c5\u5f88\u7b80\u5355
#tar zxvf http_load-12mar2006.tar.gz
#cd http_load-12mar2006
#make && make install<\/p>\n

\u547d\u4ee4\u683c\u5f0f\uff1ahttp_load -p \u5e76\u53d1\u8bbf\u95ee\u8fdb\u7a0b\u6570 -s \u8bbf\u95ee\u65f6\u95f4 \u9700\u8981\u8bbf\u95ee\u7684URL\u6587\u4ef6<\/p>\n

\u53c2\u6570\u5176\u5b9e\u53ef\u4ee5\u81ea\u7531\u7ec4\u5408\uff0c\u53c2\u6570\u4e4b\u95f4\u7684\u9009\u62e9\u5e76\u6ca1\u6709\u4ec0\u4e48\u9650\u5236\u3002\u6bd4\u5982\u4f60\u5199\u6210http_load -parallel 5 -seconds<\/p>\n

300 urls.txt\u4e5f\u662f\u53ef\u4ee5\u7684\u3002\u6211\u4eec\u628a\u53c2\u6570\u7ed9\u5927\u5bb6\u7b80\u5355\u8bf4\u660e\u4e00\u4e0b\u3002
-parallel \u7b80\u5199-p \uff1a\u542b\u4e49\u662f\u5e76\u53d1\u7684\u7528\u6237\u8fdb\u7a0b\u6570\u3002
-fetches \u7b80\u5199-f \uff1a\u542b\u4e49\u662f\u603b\u8ba1\u7684\u8bbf\u95ee\u6b21\u6570
-rate   \u7b80\u5199-p \uff1a\u542b\u4e49\u662f\u6bcf\u79d2\u7684\u8bbf\u95ee\u9891\u7387
-seconds\u7b80\u5199-s \uff1a\u542b\u4e49\u662f\u603b\u8ba1\u7684\u8bbf\u95ee\u65f6\u95f4<\/p>\n

\u51c6\u5907URL\u6587\u4ef6\uff1aurllist.txt\uff0c\u6587\u4ef6\u683c\u5f0f\u662f\u6bcf\u884c\u4e00\u4e2aURL\uff0cURL\u6700\u597d\u8d85\u8fc750\uff0d100\u4e2a\u6d4b\u8bd5\u6548\u679c\u6bd4\u8f83\u597d.\u6587\u4ef6\u683c\u5f0f<\/p>\n

\u5982\u4e0b\uff1a
http:\/\/www.vpser.net\/uncategorized\/choose-vps.html<\/a>
http:\/\/www.vpser.net\/vps-cp\/hypervm-tutorial.html<\/a>
http:\/\/www.vpser.net\/coupons\/diavps-april-coupons.html<\/a>
http:\/\/www.vpser.net\/security\/vps-backup-web-mysql.html<\/a>
\u4f8b\u5982\uff1a<\/p>\n

http_load -p 30 -s 60 urllist.txt
\u53c2\u6570\u4e86\u89e3\u4e86\uff0c\u6211\u4eec\u6765\u770b\u8fd0\u884c\u4e00\u6761\u547d\u4ee4\u6765\u770b\u770b\u5b83\u7684\u8fd4\u56de\u7ed3\u679c
\u547d\u4ee4\uff1a% .\/http_load -rate 5 -seconds 10 urls\u8bf4\u660e\u6267\u884c\u4e86\u4e00\u4e2a\u6301\u7eed\u65f6\u95f410\u79d2\u7684\u6d4b\u8bd5\uff0c\u6bcf\u79d2\u7684\u9891\u7387\u4e3a5\u3002<\/p>\n

49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds5916 mean bytes\/connection4.89274<\/p>\n

fetches\/sec, 28945.5 bytes\/secmsecs\/connect: 28.8932 mean, 44.243 max, 24.488 minmsecs\/first<\/p>\n

-response: 63.5362 mean, 81.624 max, 57.803 minHTTP response codes: code 200 — 49<\/p>\n

\u7ed3\u679c\u5206\u6790\uff1a
1\uff0e49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
\u8bf4\u660e\u5728\u4e0a\u9762\u7684\u6d4b\u8bd5\u4e2d\u8fd0\u884c\u4e8649\u4e2a\u8bf7\u6c42\uff0c\u6700\u5927\u7684\u5e76\u53d1\u8fdb\u7a0b\u6570\u662f2\uff0c\u603b\u8ba1\u4f20\u8f93\u7684\u6570\u636e\u662f289884bytes\uff0c\u8fd0\u884c\u7684\u65f6\u95f4\u662f10.0148\u79d2
2\uff0e5916 mean bytes\/connection\u8bf4\u660e\u6bcf\u4e00\u8fde\u63a5\u5e73\u5747\u4f20\u8f93\u7684\u6570\u636e\u91cf289884\/49=5916
3\uff0e4.89274 fetches\/sec, 28945.5 bytes\/sec
\u8bf4\u660e\u6bcf\u79d2\u7684\u54cd\u5e94\u8bf7\u6c42\u4e3a4.89274\uff0c\u6bcf\u79d2\u4f20\u9012\u7684\u6570\u636e\u4e3a28945.5 bytes\/sec
4\uff0emsecs\/connect: 28.8932 mean, 44.243 max, 24.488 min\u8bf4\u660e\u6bcf\u8fde\u63a5\u7684\u5e73\u5747\u54cd\u5e94\u65f6\u95f4\u662f28.8932 msecs<\/p>\n

\uff0c\u6700\u5927\u7684\u54cd\u5e94\u65f6\u95f444.243 msecs\uff0c\u6700\u5c0f\u7684\u54cd\u5e94\u65f6\u95f424.488 msecs
5\uff0emsecs\/first-response: 63.5362 mean, 81.624 max, 57.803 min
6\u3001HTTP response codes: code 200 — 49    \u8bf4\u660e\u6253\u5f00\u54cd\u5e94\u9875\u9762\u7684\u7c7b\u578b\uff0c\u5982\u679c403\u7684\u7c7b\u578b\u8fc7\u591a\uff0c\u90a3\u53ef\u80fd<\/p>\n

\u8981\u6ce8\u610f\u662f\u5426\u7cfb\u7edf\u9047\u5230\u4e86\u74f6\u9888\u3002
\u7279\u6b8a\u8bf4\u660e\uff1a
\u6d4b\u8bd5\u7ed3\u679c\u4e2d\u4e3b\u8981\u7684\u6307\u6807\u662f fetches\/sec\u3001msecs\/connect \u8fd9\u4e2a\u9009\u9879\uff0c\u5373\u670d\u52a1\u5668\u6bcf\u79d2\u80fd\u591f\u54cd\u5e94\u7684\u67e5\u8be2\u6b21\u6570\uff0c<\/p>\n

\u7528\u8fd9\u4e2a\u6307\u6807\u6765\u8861\u91cf\u6027\u80fd\u3002\u4f3c\u4e4e\u6bd4 apache\u7684ab\u51c6\u786e\u7387\u8981\u9ad8\u4e00\u4e9b\uff0c\u4e5f\u66f4\u6709\u8bf4\u670d\u529b\u4e00\u4e9b\u3002
Qpt-\u6bcf\u79d2\u54cd\u5e94\u7528\u6237\u6570\u548cresponse time\uff0c\u6bcf\u8fde\u63a5\u54cd\u5e94\u7528\u6237\u65f6\u95f4\u3002
\u6d4b\u8bd5\u7684\u7ed3\u679c\u4e3b\u8981\u4e5f\u662f\u770b\u8fd9\u4e24\u4e2a\u503c\u3002\u5f53\u7136\u4ec5\u6709\u8fd9\u4e24\u4e2a\u6307\u6807\u5e76\u4e0d\u80fd\u5b8c\u6210\u5bf9\u6027\u80fd\u7684\u5206\u6790\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u5bf9\u670d\u52a1\u5668\u7684<\/p>\n

cpu\u3001men\u8fdb\u884c\u5206\u6790\uff0c\u624d\u80fd\u5f97\u51fa\u7ed3\u8bba<\/p>\n

\u4e8c\u3001webbench<\/strong><\/p>\n

webbench\u662fLinux\u4e0b\u7684\u4e00\u4e2a\u7f51\u7ad9\u538b\u529b\u6d4b\u8bd5\u5de5\u5177\uff0c\u6700\u591a\u53ef\u4ee5\u6a21\u62df3\u4e07\u4e2a\u5e76\u53d1\u8fde\u63a5\u53bb\u6d4b\u8bd5\u7f51\u7ad9\u7684\u8d1f\u8f7d\u80fd\u529b\u3002\u4e0b\u8f7d\u5730\u5740\u53ef\u4ee5\u5230google\u641c\uff0c\u6211\u8fd9\u91cc\u7ed9\u51fa\u4e00\u4e2a
\u4e0b\u8f7d\u5730\u5740\uff1a
http:\/\/soft.vpser.net\/test\/webbench\/webbench-1.5.tar.gz<\/a>
\u8fd9\u4e2a\u7a0b\u5e8f\u66f4\u5c0f\uff0c\u89e3\u538b\u540e\u4e0d\u523050K\uff0c\u5475\u5475
\u5b89\u88c5\u975e\u5e38\u7b80\u5355
#tar zxvf webbench-1.5.tar.gz
#cd webbench-1.5
#make && make install
\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u751f\u6210webbench\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u76f4\u63a5\u53ef\u4ee5\u4f7f\u7528\u4e86<\/p>\n

\u7528\u6cd5\uff1a<\/p>\n

webbench -c \u5e76\u53d1\u6570 -t \u8fd0\u884c\u6d4b\u8bd5\u65f6\u95f4 URL
\u5982\uff1a
webbench -c 5000 -t 120
http:\/\/www.vpser.net<\/a><\/p>\n

\u4e09\u3001ab<\/strong>
ab\u662fapache\u81ea\u5e26\u7684\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u6d4b\u8bd5\u5de5\u5177
\u5b89\u88c5\u4e86apache\u4e00\u822c\u5c31\u81ea\u5e26\u4e86\uff0c
\u7528\u6cd5\u53ef\u4ee5\u67e5\u770b\u5b83\u7684\u8bf4\u660e<\/p>\n

$ .\/ab
.\/ab: wrong number of arguments
Usage: .\/ab [options] [http:\/\/]hostname[:port]\/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-p postfile File containing data to POST
-T content-type Content-type header for POSTing
-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
-h Display usage information (this message)
\u53c2\u6570\u4f17\u591a\uff0c\u4e00\u822c\u6211\u4eec\u7528\u5230\u7684\u662f-n \u548c-c
\u4f8b\u5982\uff1a
.\/ab -c 1000 -n 100
http:\/\/www.vpser.net\/index.php<\/a><\/p>\n

Concurrency Level:     1000
\/\/\u5e76\u53d1\u6570
Time taken for tests:  8.188731 seconds
\/\/\u6574\u4e2a\u6d4b\u8bd5\u6301\u7eed\u7684\u65f6\u95f4
Complete requests:     1000
\/\/\u5b8c\u6210\u7684\u8bf7\u6c42\u6570\u91cf
Failed requests:       0
\/\/\u5931\u8d25\u7684\u8bf7\u6c42\u6570\u91cf
Requests per second:   122.12 [#\/sec] (mean)
\/\/\u5927\u5bb6\u6700\u5173\u5fc3\u7684\u6307\u6807\u4e4b\u4e00\uff0c\u76f8\u5f53\u4e8e LR \u4e2d\u7684\u6bcf\u79d2\u4e8b\u52a1\u6570\uff0c\u540e\u9762\u62ec\u53f7\u4e2d\u7684 mean \u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u5e73\u5747\u503c
Time per request:      8188.731 [ms] (mean)
\/\/\u5927\u5bb6\u6700\u5173\u5fc3\u7684\u6307\u6807\u4e4b\u4e8c\uff0c\u76f8\u5f53\u4e8e LR \u4e2d\u7684\u5e73\u5747\u4e8b\u52a1\u54cd\u5e94\u65f6\u95f4\uff0c\u540e\u9762\u62ec\u53f7\u4e2d\u7684 mean \u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u5e73\u5747\u503c
Time per request:      8.189 [ms] (mean, across all concurrent requests)
\/\/\u6bcf\u4e2a\u8bf7\u6c42\u5b9e\u9645\u8fd0\u884c\u65f6\u95f4\u7684\u5e73\u5747\u503c
Transfer rate:         162.30 [Kbytes\/sec] received
\/\/\u5e73\u5747\u6bcf\u79d2\u7f51\u7edc\u4e0a\u7684\u6d41\u91cf\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6392\u9664\u662f\u5426\u5b58\u5728\u7f51\u7edc\u6d41\u91cf\u8fc7\u5927\u5bfc\u81f4\u54cd\u5e94\u65f6\u95f4\u5ef6\u957f\u7684\u95ee\u9898<\/p>\n

\u8fd9\u4e2a\u8868\u793a\u540c\u65f6\u5904\u74061000\u4e2a\u8bf7\u6c42\u5e76\u8fd0\u884c100\u6b21index.php\u6587\u4ef6.<\/p>\n

\u56db\u3001Siege
<\/strong>\u4e00\u6b3e\u5f00\u6e90\u7684\u538b\u529b\u6d4b\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u6839\u636e\u914d\u7f6e\u5bf9\u4e00\u4e2aWEB\u7ad9\u70b9\u8fdb\u884c\u591a\u7528\u6237\u7684\u5e76\u53d1\u8bbf\u95ee\uff0c\u8bb0\u5f55\u6bcf\u4e2a\u7528\u6237\u6240\u6709\u8bf7\u6c42\u8fc7\u7a0b\u7684\u76f8\u5e94\u65f6\u95f4\uff0c\u5e76\u5728\u4e00\u5b9a\u6570\u91cf\u7684\u5e76\u53d1\u8bbf\u95ee\u4e0b\u91cd\u590d\u8fdb\u884c\u3002
\u5b98\u65b9\uff1a
http:\/\/www.joedog.org\/<\/a>
Siege\u4e0b\u8f7d\uff1a
http:\/\/soft.vpser.net\/test\/siege\/siege-2.67.tar.gz<\/a>
\u89e3\u538b\uff1a
# tar -zxf siege-2.67.tar.gz
\u8fdb\u5165\u89e3\u538b\u76ee\u5f55\uff1a
# cd siege-2.67\/
\u5b89\u88c5\uff1a
#.\/configure ; make
#make install<\/p>\n

\u4f7f\u7528
siege -c 200 -r 10 -f example.url
-c\u662f\u5e76\u53d1\u91cf\uff0c-r\u662f\u91cd\u590d\u6b21\u6570\u3002 url\u6587\u4ef6\u5c31\u662f\u4e00\u4e2a\u6587\u672c\uff0c\u6bcf\u884c\u90fd\u662f\u4e00\u4e2aurl\uff0c\u5b83\u4f1a\u4ece\u91cc\u9762\u968f\u673a\u8bbf\u95ee\u7684\u3002<\/p>\n

example.url\u5185\u5bb9:<\/p>\n

http:\/\/www.licess.cn<\/a>
http:\/\/www.vpser.net<\/a>
http:\/\/soft.vpser.net<\/a><\/p>\n

\u7ed3\u679c\u8bf4\u660e
Lifting the server siege\u2026 done.
Transactions: 3419263 hits \/\/\u5b8c\u6210419263\u6b21\u5904\u7406
Availability: 100.00 % \/\/100.00 % \u6210\u529f\u7387
Elapsed time: 5999.69 secs \/\/\u603b\u5171\u7528\u65f6
Data transferred: 84273.91 MB \/\/\u5171\u6570\u636e\u4f20\u8f9384273.91 MB
Response time: 0.37 secs \/\/\u76f8\u5e94\u7528\u65f61.65\u79d2\uff1a\u663e\u793a\u7f51\u7edc\u8fde\u63a5\u7684\u901f\u5ea6
Transaction rate: 569.91 trans\/sec \/\/\u5747\u6bcf\u79d2\u5b8c\u6210 569.91 \u6b21\u5904\u7406\uff1a\u8868\u793a\u670d\u52a1\u5668\u540e
Throughput: 14.05 MB\/sec \/\/\u5e73\u5747\u6bcf\u79d2\u4f20\u9001\u6570\u636e
Concurrency: 213.42 \/\/\u5b9e\u9645\u6700\u9ad8\u5e76\u53d1\u6570
Successful transactions: 2564081 \/\/\u6210\u529f\u5904\u7406\u6b21\u6570
Failed transactions: 11 \/\/\u5931\u8d25\u5904\u7406\u6b21\u6570
Longest transaction: 29.04 \/\/\u6bcf\u6b21\u4f20\u8f93\u6240\u82b1\u6700\u957f\u65f6\u95f4
Shortest transaction: 0.00 \/\/\u6bcf\u6b21\u4f20\u8f93\u6240\u82b1\u6700\u77ed\u65f6\u95f4<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4e00\u3001http_load<\/strong><\/p>\n

\u7a0b\u5e8f\u975e\u5e38\u5c0f\uff0c\u89e3\u538b\u540e\u4e5f\u4e0d\u5230100K<\/p>\n

http_load\u4ee5\u5e76\u884c\u590d\u7528\u7684\u65b9\u5f0f\u8fd0\u884c\uff0c\u7528\u4ee5\u6d4b\u8bd5web\u670d\u52a1\u5668\u7684\u541e\u5410\u91cf\u4e0e\u8d1f\u8f7d\u3002\u4f46\u662f\u5b83\u4e0d\u540c\u4e8e\u5927\u591a\u6570\u538b\u529b\u6d4b\u8bd5\u5de5<\/p>\n

\u5177\uff0c\u5b83\u53ef\u4ee5\u4ee5\u4e00\u4e2a\u5355\u4e00\u7684\u8fdb\u7a0b\u8fd0\u884c\uff0c\u4e00\u822c\u4e0d\u4f1a\u628a\u5ba2\u6237\u673a\u641e\u6b7b\u3002\u8fd8\u53ef\u4ee5\u6d4b\u8bd5HTTPS\u7c7b\u7684\u7f51\u7ad9\u8bf7\u6c42\u3002<\/p>\n

\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/soft.vpser.net\/test\/http_load\/http_load-12mar2006.tar.gz<\/a>
\u5b89\u88c5\u5f88\u7b80\u5355
#tar zxvf http_load-12mar2006.tar.gz
#cd http_load-<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1005"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1005"}],"version-history":[{"count":0,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1005\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}