Apache 的 ab 壓測工具快速使用
阿新 • • 發佈:2017-11-14
second request cnblogs nis ini mic roc quest connect
ab 是一個 httpd 自帶的很好用的壓力測試工具,它是 apache bench 命令的縮寫。ab 命令會創建多個並發訪問線程,模擬多個訪問者同時對某一 URL 地址進行訪問。可以用來測試 apache 的負載壓力,也可以用來測試 nginx、lighthttp、tomcat、IIS 等其它 Web 服務器的壓力負載性能。
安裝
yum -y install httpd-tools
查看是否安裝成功
ab -V
help 查看 ab 參數詳細說明
ab --help
正式壓測
ab -n 100 -c 20 http://www.baidu.com
-n 表示 100 個請求,-c 模擬 20 並發,相當於20個人同時訪問後面的測試 URL
ab -t 60 -c 100 http://www.baidu.com
在 60s 內發請求,一次 100 個請求
結果參數解釋
Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Finished 800 requests Server Software: Microsoft-HTTPAPI/2.0表示被測試的Web服務器軟件名稱 Server Hostname: 192.168.0.10 表示請求的URL主機名 Server Port: 80 表示被測試的Web服務器軟件的監聽端口 Document Path: / 表示請求的URL中的根絕對路徑,通過該文件的後綴名,我們一般可以了解該請求的類型 Document Length: 315 bytes 表示HTTP響應數據的正文長度 Concurrency Level:800 表示並發用戶數,是我們設置的參數之一 Time taken for tests: 0.914 seconds 所有這些請求處理完成所花費的時間 Complete requests: 800 完成請求數 Failed requests: 0 失敗請求數 Write errors: 0 Non-2xx responses: 800 Total transferred: 393600 bytes 網絡總傳輸量 HTML transferred: 252000 bytes HTML內容傳輸量 Requests per second: 875.22 [#/sec] (mean) 吞吐量-每秒請求數 Time per request: 914.052 [ms] (mean) 服務器收到請求,響應頁面要花費的時間 Time per request: 1.143 [ms] (mean, across all concurrent requests) 並發的每個請求平均消耗時間 Transfer rate: 420.52 [Kbytes/sec] received 平均每秒網絡上的流量,可以幫助排除是否存在網絡流量過大導致響應時間延長的問題
網絡上消耗的時間的分解:
Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 0.5 1 3 Processing: 245 534 125.2 570 682 Waiting: 11 386 189.1 409 669 Total: 246 535 125.0 571 684
整個場景中所有請求的響應情況。在場景中每個請求都有一個響應時間
其中 50% 的用戶響應時間小於 571 毫秒
80% 的用戶響應時間小於 652 毫秒
最大的響應時間小於 684 毫秒
Percentage of the requests served within a certain time (ms) 50% 571 66% 627 75% 646 80% 652 90% 666 95% 677 98% 681 99% 682 100% 684 (longest request)
Apache 的 ab 壓測工具快速使用