壓力測試工具-webbench


簡述

偶然情況下看到一款性能測試工具webbench,看着挺不錯的記錄一下安裝過程,在以后項目上線過程中可以壓一壓一些頁面的並發情況,對項目性能有個大致的了解。

原理

webbench首先fork出多個子進程,每個子進程都循環做web訪問測試。子進程把訪問的結果通過pipe告訴父進程,父進程做最終的統計結果百科介紹

安裝過程

[root@node1 ~]# yum install -y gcc ctags
[root@node1 ~]# wget http://www.ha97.com/code/webbench-1.5.tar.gz
[root@node1 ~]# tar -xvf  webbench-1.5.tar.gz
[root@node1 data]# cd webbench-1.5
[root@node1 webbench-1.5]# make && make install    ##這一步可能遇到如下錯誤,手動創建目錄即可
cc -Wall -ggdb -W -O   -c -o webbench.o webbench.c
webbench.c: In function 鈥榓larm_handler鈥

                                           webbench.c:77: warning: unused parameter 鈥榮ignal鈥
cc -Wall -ggdb -W -O  -o webbench webbench.o  
ctags *.c
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
[root@node1 webbench-1.5]# mkdir /usr/local/man
[root@node1 webbench-1.5]# mkdir /usr/local/man/man1
[root@node1 webbench-1.5]# make &&make install
make: Nothing to be done for `all'.
install -s webbench /usr/local/bin
install -m 644 webbench.1 /usr/local/man/man1
install -d /usr/local/share/doc/webbench
install -m 644 debian/copyright /usr/local/share/doc/webbench
install -m 644 debian/changelog /usr/local/share/doc/webbench

使用說明 通過webbench --help 命令查看

[root@node1 data]# 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.

使用

不是專業測試,再次使用此工具模擬對一個項目進行壓測,使用兩個參數 c 並發客戶端數,t 運行時長,我們來對http://www.baidu.com 做壓測看測試報告內容

執行命令:webbench -c 10 http://www.baidu.com
命令就是用10個客戶端並發百度網站30秒,但是在執行的命令報錯了:Invalid URL syntax - hostname don't ends with '/'。解決辦法就是在url后加個“/”

執行結果反饋內容:

[root@node1 data]# webbench -c 10 -t 30 http://www.baidu.com/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://www.baidu.com/
10 clients, running 30 sec.

Speed=2254 pages/min, 4188293 bytes/sec.
Requests: 1110 susceed, 17 failed.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM