web性能測試工具 SuperWebBench
SuperWebBench 是由webbench改進而來的一款簡單易用的web性能測試工具.
背景:
webbench最多可以模擬3萬個并發連接去測試網站的負載能力,個人感覺要比Apache自帶的ab壓力測試工具好,安裝使用也特別方便。
webbench是基于GPL授權協議的,我自然可以取得源碼修改,然后作為superwebbench這個項目發布。
簡介:
SuperWebBench 是由webbench改進而來的一款簡單易用的web性能測試工具
SuperWebBench 是依照GPL V2.0發布的
SuperWebBench是遵循POSIX標準的C語言編寫的程序
主要改動如下:
1、更正connect()服務器失敗時,不能close()的bug
2、使用多線程代替多進程,提供更高的效率
3、自動資源限制檢測和設置(線程數和打開文件數限制)
4、測試時間到達后,快速關閉套接字,不用再等待服務器響應(在WAN的情況下,這會占用很多時間)
5、加入了檢測HTTP響應號的功能,這樣就可以分辨HTTP是否返回了正確的信息(HTTP2XX)
6、重新組織了下代碼結構,使得閱讀更方便
安裝:
wget http://www.teamhost.org/attachments/download/77/SuperWebBench.tar.gz
tar zxvf SuperWebBench.tar.gz
cd superwebbench
make && make install
superwebbench -c 500 -t 30 http://127.0.0.1/test.jpg
參數說明:-c表示并發數,-t表示時間(秒)
測試結果示例:
SuperWebBench - Advanced Simple Web Benchmark 0.1
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Modified By Davelv 2011-11-03
Benchmarking:GET http://127.0.0.1/test.jpg (using HTTP/1.1)
500 clients, running 30 sec.
Speed=5887 pages/sec, 1862058 bytes/sec.
Requests: 0 ok, 176220 http error, 405 failed.
示范:
superwebbench
superwebbench [option]... URL
-f|--force Don't wait for reply from server.
-r|--reload Send reload request - Pragma: no-cache.
-t|--time <sec> Run benchmark for <sec> seconds. Default 30.
-p|--proxy <server:port> Use proxy server for request.
-c|--clients <n> Run <n> HTTP clients at once. Default one.
-9|--http09 Use HTTP/0.9 style requests.
-1|--http10 Use HTTP/1.0 protocol.
-2|--http11 Use HTTP/1.1 protocol.
--get Use GET request method.
--head Use HEAD request method.
--options Use OPTIONS request method.
--trace Use TRACE request method.
-?|-h|--help This information.
-V|--version Display program version.
常見問題:
ctags *.c
/bin/sh: ctags: command not found
make: [tags] 錯誤 127 (忽略)
ok,是在centos下沒自動安裝ctags命令,于是yum install ctags,安裝成功。