压测—ab
ab(apache bench):apache下的一個工具,主要用于做web站點的壓力測試
?1. Ubuntu安裝ab命令
sudo apt-get install apache2-utils
?若報錯:
Err:1 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-utils amd64 2.4.29-1ubuntu4.14
? 404 ?Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-utils_2.4.29-1ubuntu4.14_amd64.deb ?404 ?Not Found [IP: 91.189.88.152 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
解決方式:
(1)修改源:sudo gedit /etc/apt/sources.list
(2)打開的文件最后添加如下兩行
? ? ? ? deb?http://dk.archive.ubuntu.com/ubuntu/ xenial main
????????deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe
(3)更新源:sudo apt update
(4)再次安裝:sudo apt-get install apache2-utils
?2. 常用參數
執行ab --help查看參數:
-n:總共的請求執行數,缺省是1;-c:并發數,缺省是1;-t:測試所進行的總時間,秒為單位,缺省50000s-p:POST時的數據文件-w: 以HTML表的格式輸出結果3. 執行結果
執行??? ab -n 5000 -c 200 http://localhost/test.php:
Benchmarking localhost (be patient) Completed 500 requests Completed 1000 requests Completed 1500 requests Completed 2000 requests Completed 2500 requests Completed 3000 requests Completed 3500 requests Completed 4000 requests Completed 4500 requests Completed 5000 requests Finished 5000 requests //執行完的請求次數Server Software: Apache/2.4.3 //apache版本 Server Hostname: localhost //主機 Server Port: 80 //端口Document Path: /test.php //路徑 Document Length: 62492 bytes Concurrency Level: 200???????????????? //并發數 Time taken for tests: 3.927 seconds //完成此次請求時間 Complete requests: 5000 //完成請求次數 Failed requests: 527 //失敗的請求次數(Connect: 0, Receive: 0, Length: 527, Exceptions: 0) Total transferred: 313289422 bytes //總共傳輸字節 HTML transferred: 312459422 bytes Requests per second: 1273.33 [#/sec] (mean) //每秒請求次數:平均每秒處理1273個請求次數 Time per request: 157.069 [ms] (mean) //一次請求時間:平均每個請求處理時間為157毫秒 Time per request: 0.785 [ms] (mean, across all concurrent requests) //平均每個并發請求處理 時間 為0.785毫秒 Transfer rate: 77914.14 [Kbytes/sec] received //傳輸速率Connection Times (ms)min mean[+/-sd] median max Connect: 0 6 73.1 0 1001 Processing: 2 150 143.9 111 1626 Waiting: 2 137 135.3 103 1197 Total: 2 155 160.3 111 1626Percentage of the requests served within a certain time (ms)50% 111 //在這5000個請求中有50%在111毫秒內完成66% 141??????//在這5000個請求中有66%在141毫秒內完成 75% 16880% 19190% 31095% 45298% 67399% 951100% 1626 (longest request)總結
- 上一篇: NER数据增强、badcase处理、数据
- 下一篇: RE2—C++