ab是apache自帶的網站壓力測試工具。
使用起來非常的簡單和方便。
不僅僅是可以apache服務器進行網站訪問壓力測試,還可以對其他類型的服務器進行壓力測試。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
Usage: ab.exe [options] [http://]hostname[:port]/path Options are: -n requests Number of requests to perform -c concurrency Number of multiple requests to make at a time -t timelimit Seconds to max. to spend on benchmarking This implies -n 50000 -s timeout Seconds to max. wait for each response Default is 30 seconds -b windowsize Size of TCP send/receive buffer, in bytes -B address Address to bind to when making outgoing connections -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 to use for POST/PUT data, 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. -q Do not show progress when doing more than 150 requests -l Accept variable document length (use this for dynamic pages) -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. -m method Method name -h Display usage information (this message) |
舉例:
ab.exe -c5000 -n50000 -k http://192.168.1.101/
結果返回,為了方便,省略部分中間請求文字顯示,同時為了方便講解,在請求回來的地方予以注釋說明:
8核/4G內存 虛擬機 Nginx 靜態(tài)文檔 壓測結果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
This is ApacheBench, Version 2.3 <$Revision: 1874286 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.101 (be patient) Completed 5000 requests ......(中間過程省略,5000一個一個的數) Finished 50000 requests Server Software: nginx/1.18.0 //服務器軟件版本 Server Hostname: 192.168.1.101 //服務器主機 Server Port: 80 //服務器端口 Document Path: / //文檔路徑 Document Length: 13 bytes //單個文檔大小 Concurrency Level: 5000 //并發(fā)數量 Time taken for tests: 5.310 seconds //測試完成時間 Complete requests: 50000 //完成請求數量 Failed requests: 0 //失敗請求數量 Keep-Alive requests: 50000 //保持長鏈接請求數量 Total transferred: 13150000 bytes //總的請求字節(jié)數 HTML transferred: 650000 bytes //返回請求字節(jié)數 Requests per second: 9416.54 [#/sec] (mean) //每秒處理請求數量 Time per request: 530.980 [ms] (mean) //平均響應時間 Time per request: 0.106 [ms] (mean, across all concurrent requests) //平均請求處理時間 Transfer rate: 2418.51 [Kbytes/sec] received //每秒網絡傳輸的數據量 Connection Times (ms) //消耗時間分析 min mean[+/-sd] median max Connect: 0 0 0.3 0 19 Processing: 53 385 373.4 246 2306 Waiting: 1 384 373.3 246 2305 Total: 53 385 373.5 246 2306 Percentage of the requests served within a certain time (ms) //請求處理分布百分比 50% 246 66% 312 75% 417 80% 447 90% 737 95% 1242 98% 1801 99% 2042 100% 2306 (longest request) //50%的用戶響應時間小于246ms //66%的用戶響應時間小于312ms |
關鍵參數:
1 |
<strong>Requests per second</strong> |