http壓力測試工具及使用說明
轉
說明:介紹幾款簡單、易使用http壓測工具,便于研發同學,壓測服務,明確服務臨界值,尋找服務瓶頸點。
壓測時候可重點以下指標,關注并發用戶數、TPS(每秒事務數量)、RT(事務響應時間)、事物失敗率、CPU(不要超過70%)、LOAD(4核以下服務,不要超過2)
?
- http_load
- Apache Bench(Apache自帶服務器壓力測試工具)
- webbench
?
http_load
以并行復用的方式運行,以測試web服務器的吞吐量與負載。不同于大多數壓力測試工具,它是單進程,所以一般不會把客戶機搞死,也可以測試https類網站的請求。
支持多個url。
官方網站
wget http: //acme.com/software/http_load/http_load-14aug2014.tar.gz tar zxvf http_load-14aug2014.tar.gz ln -s http_load-14aug2014 http_load cd http_load make && make install ? /Users/yxy/data/soft/http_load >http_load --help usage:? http_load [-checksum] [-throttle] [-proxy host:port] [-verbose] [-timeout secs] [-sip sip_file] ???????????? -parallel N | -rate N [-jitter] ???????????? -fetches N | -seconds N ???????????? url_file One start specifier, either -parallel or -rate, is required. One end specifier, either -fetches or -seconds, is required. 參數簡單說明 -parallel 簡寫-p:并發的用戶數 -rate???? 簡寫-r:每秒訪問次數 -fetches? 簡寫-f:總計訪問次數 -seconds? 簡寫-s:持續訪問時間 url_file? 壓測url(文件形式,需要訪問的url,支持多個,每行一個) |
執行實例
? /Users/yxy/data/soft/http_load >http_load -p? 10 ?-s? 10 ?urls?? # 10 個并發用戶,連續不停訪問10s, 182 ?fetches,? 10 ?max parallel,? 1 .03449e+ 06 ?bytes, in? 10.0038 ?seconds -- 182 次訪問,最大并發數是 10 ,總計傳輸數據 1 .03449e+ 06 字節,運行時間 10 秒 5684 ?mean bytes/connection 18.1932 ?fetches/sec,? 103410 ?bytes/sec --每秒的響應請求 18.1932 ,每秒傳遞的數據為 103410 字節 msecs/connect:? 24.8529 ?mean,? 1048.38 ?max,? 4.062 ?min --連接平均響應時間是 24.85 毫秒,最大響應時間 1048 毫秒,最小響應時間 4 毫秒 msecs/first-response:? 483.459 ?mean,? 683.458 ?max,? 164.157 ?min --每次連接平均返回時間 平均,最大,最小 HTTP response codes: ?? code? 200 ?--? 182 |
?
Apache Bench(Apache自帶服務器壓力測試工具)
? /Users/yxy >ab -c? 10 ?-n? 50 ?http: //192.168.100.152:18800/casefolder-social/question/detail?shareUID=40d0c000-09b6-416c-b626-b9ce61399d07 -- -n 表示:每次請求數,默認不能超過 1024 個,-c表示: 1 個請求的并發連接數,默認最大不能超過 50000 。 -- 模擬 50 個并發連接每次以 100 個請求數來測試網站的Web性能 This is ApacheBench, Version? 2.3 ?<$Revision:? 1663405 ?$> Copyright? 1996 ?Adam Twiss, Zeus Technology Ltd, http: //www.zeustech.net/ Licensed to The Apache Software Foundation, http: //www.apache.org/ Benchmarking? 192.168 . 100.152 ?(be patient).....done Server Software:??????? Apache-Coyote/ 1.1 Server Hostname:???????? 192.168 . 100.152 Server Port:???????????? 18800 Document Path:????????? /casefolder-social/question/detail?shareUID=40d0c000-09b6-416c-b626-b9ce61399d07 Document Length:???????? 641 ?bytes Concurrency Level:?????? 10 Time taken? for ?tests:??? 0.703 ?seconds Complete requests:?????? 50 Failed requests:???????? 0 Total transferred:?????? 39100 ?bytes HTML transferred:??????? 32050 ?bytes Requests per second:???? 71.16 ?[#/sec] (mean) Time per request:??????? 140.532 ?[ms] (mean) Time per request:??????? 14.053 ?[ms] (mean, across all concurrent requests) Transfer rate:?????????? 54.34 ?[Kbytes/sec] received Connection Times (ms) ?????????????? min? mean[+/-sd] median?? max Connect:???????? 6 ???21 ??26.4 ?????13 ?????102 Processing:???? 87 ??114 ??50.9 ????107 ?????460 Waiting:??????? 84 ??114 ??51.0 ????106 ?????459 Total:???????? 100 ??136 ??58.2 ????119 ?????473 Percentage of the requests served within a certain time (ms) ?? 50 %???? 119 ?? 66 %???? 126 ?? 75 %???? 131 ?? 80 %???? 132 ?? 90 %???? 217 ?? 95 %???? 223 ?? 98 %???? 473 ?? 99 %???? 473 ? 100 %???? 473 ?(longest request) |
webbench
使用方式和http_load相似,指標較為簡單
webbench是Linux下的一個網站壓力測試工具,最多可以模擬3萬個并發連接去測試網站的負載能力。
下載地址:http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz
安裝非常簡單
#tar zxvf webbench- 1.5 .tar.gz #cd webbench- 1.5 #make && make install |
會在當前目錄生成webbench可執行文件,直接可以使用了
用法:webbench -c 并發數 -t 運行測試時間 URL
例如:
/Users/yxy/data/soft/webbench >webbench -c?? 10 ?-t? 30 ?http: //192.168.100.152:18800/casefolder-social/question/detail\?shareUID\=40d0c000-09b6-416c-b626-b9ce61399d07 Webbench - Simple Web Benchmark? 1.5 Copyright (c) Radim Kolar? 1997 - 2004 , GPL Open Source Software. Benchmarking: GET http: //192.168.100.152:18800/casefolder-social/question/detail?shareUID=40d0c000-09b6-416c-b626-b9ce61399d07 10 ?clients, running? 30 ?sec. Speed= 3958 ?pages/min,? 51585 ?bytes/sec. Requests:? 1979 ?susceed,? 0 ?failed. |