偶然狀況下看到一款性能測試工具webbench,看着挺不錯的記錄一下安裝過程,在之後項目上線過程當中能夠壓一壓一些頁面的併發狀況,對項目性能有個大體的瞭解。node
webbench首先fork出多個子進程,每一個子進程都循環作web訪問測試。子進程把訪問的結果經過pipe告訴父進程,父進程作最終的統計結果百科介紹linux
[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
[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 作壓測看測試報告內容web
執行命令: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.