wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz tar zxvf webbench-1.5.tar.gz cd webbench-1.5 make && make install
若是在編譯webbench的時候,出現/bin/sh: ctags: command not found,以下 html
[root@webbench-1.5]# make cc -Wall -ggdb -W -O -c -o webbench.o webbench.c webbench.c: In function ‘alarm_handler’: webbench.c:77: warning: unused parameter ’signal’ cc -Wall -ggdb -W -O -o webbench webbench.o ctags *.c /bin/sh: ctags: command not found make: [tags] Error 127 (ignored)
是沒安裝ctags組件, linux
sudo apt-get install exuberant-ctags若是安裝了ctags, 仍然報錯:
install -s webbench /usr/local/bin install -m 644 webbench.1 /usr/local/man/man1 install: cannot create regular file `/usr/local/man/man1′: No such file or directory make: *** [install] Error 1
解決方法 web
mkdir -m 644 -p /usr/local/man/man1
安裝好使用方法 shell
webbench -c 500 -t 30 http://127.0.0.1:8000/en
參數說明:-c表示併發數,-t表示時間(秒) centos
測試結果示例: 服務器
webbench -c 50 -t 30 http://127.0.0.1:8000/en
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://127.0.0.1:8000/en
50 clients, running 30 sec.
Speed=11464 pages/min, 65468 bytes/sec.
Requests: 5727 susceed, 5 failed. 併發
每秒鐘響應請求數:11464/60= X pages/sec,每秒鐘傳輸數據量65468 bytes/sec。 性能
當併發5727時,已經顯示有5個鏈接failed了,說明未負荷了。 測試
查看幫助: 網站
[root@centos webbench-1.5]# webbench --help
webbench [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.
測試:
# webbench -c 200 -t 30 http://hi.baidu.com/begin
--參數說明:-c表示併發數,-t表示時間(秒)
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://support.qq.com/discuss/498_1.shtml
200 clients, running 30 sec.
Speed=527 pages/min, 250141 bytes/sec.
Requests:670 susceed, 0 failed.
一、壓力及性能測試工做應該放到產品上線以前,而不是上線之後;
二、測試時併發應當由小逐漸加大,好比並發100時觀察一下網站負載是多少、打開頁面是否流暢,併發200時又是多少、網站打開緩慢時併發是多少、網站打不開時併發又是多少;
三、更詳細的進行某個頁面測試,如電商網站能夠着重測試購物車、推廣頁面等,由於這些頁面佔整個網站訪問量比重較大。
備註:webbench 作壓力及性能測試時,該軟件自身也會消耗CPU和內存資源,爲了測試準確,建議將 webbench 安裝在其餘的服務器上,已達到測試數據更加精確。