壓測比較常用的工具:ab,webbench,jmeter
ab和webbench作為shell模式下輕量級的測試工具,ab比webbench功能更多一些
jmeter作為有GUI界面的更高級測試工具
ab和jmeter同是apache下的兩款壓測工具
ab是Apache組織開發的一款web壓力測試工具,優點是使用方便,統計功能強大
命令格式
ab [options] [http://]hostname[:port]/path
比較常用的有 -n, -t , -c
-c(concurrency)表示用多少並發來進行測試
-t表示測試持續多長時間
-n表示要發送多少次測試請求
eg:
D:\wamp64\bin\apache\apache2.4.39\bin>ab -n 100 -c 100 http://127.0.0.1:8080/test This is ApacheBench, Version 2.3 <$Revision: 1843412 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient).....done Server Software: Server Hostname: 127.0.0.1 Server Port: 8080 Document Path: /test Document Length: 2 bytes Concurrency Level: 100 Time taken for tests: 0.185 seconds Complete requests: 100 Failed requests: 0 Total transferred: 13400 bytes HTML transferred: 200 bytes Requests per second: 541.03 [#/sec] (mean) Time per request: 184.833 [ms] (mean) Time per request: 1.848 [ms] (mean, across all concurrent requests) Transfer rate: 70.80 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.5 0 1 Processing: 26 126 41.7 146 174 Waiting: 2 80 38.5 72 146 Total: 26 126 41.6 147 175 Percentage of the requests served within a certain time (ms) 50% 147 66% 154 75% 159 80% 161 90% 165 95% 168 98% 171 99% 175 100% 175 (longest request)
jmeter是一個非常強大和用戶友好的GUI工具,http訪問的參數設置基本應有盡有

結果


對比:
jmeter是一次完整的請求和返回;AB只是發出去請求,並不對返回做處理
jmeter可以提供更加詳細的統計結果數據;ab的結果為用數學方式統計平均值
jmeter支持可變參數和CSV數據集的輸入,能設定更加負責的測試樣例;AB不需要寫配置文件
jmeter不支持精確時間的壓測;AB支持
jmeter為GUI的較重,並且統計了很多結果數據,比AB耗時耗費資源多;AB屬於輕量級
