1. 程式人生 > >Web效能壓力測試之Webbench使用詳解

Web效能壓力測試之Webbench使用詳解

Webbench是知名的網站壓力測試工具,它是由Lionbridge公司(http://www.lionbridge.com)開發。
Webbench能測試處在相同硬體上,不同服務的效能以及不同硬體上同一個服務的執行狀況。webbench的標準測試可以向我們展示伺服器的兩項內容:每秒鐘相應請求數和每秒鐘傳輸資料量。webbench不但能具有便準靜態頁面的測試能力,還能對動態頁面(ASP,PHP,JAVA,CGI)進 行測試的能力。還有就是他支援對含有SSL的安全網站例如電子商務網站進行靜態或動態的效能測試。
Webbench最多可以模擬3萬個併發連線去測試網站的負載能力。
官方主頁:http://home.tiscali.cz/~cz210552/webbench.html
官方介紹:
Web Bench is very simple tool for benchmarking WWW or proxy servers. Uses fork() for simulating multiple clients and can use HTTP/0.9-HTTP/1.1 requests. This benchmark is not very realistic, but it can test if your HTTPD can realy handle that many clients at once (try to run some CGIs) without taking your machine down. Displays pages/min and bytes/sec. Can be used in more aggressive mode with -f switch.

1、WebBench安裝
# yum install -y gcc ctags
# wget http://www.ha97.com/code/webbench-1.5.tar.gz
# tar zxvf webbench-1.5.tar.gz
# cd webbench-1.5
# make
# make install

2、WebBench使用
webbench -c 1000 -t 60 http://test.domain.com/phpinfo.php
webbench -c 併發數 -t 執行測試時間 URL

3、測試例項結果
當併發300時:
向http://test.domain.com/phpinfo.php發起300個執行緒請求,持續時間60秒
webbench -c 300 -t 60 http://test.domain.com/phpinfo.php


Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://test.domain.com/phpinfo.php
300 clients, running 60 sec.

Speed=24525 pages/min, 20794612 bytes/sec. 
Requests: 24525 susceed, 0 failed.
速度:每秒鐘響應請求數:24525 pages/min,每秒鐘傳輸資料量20794612 bytes/sec.
返回數:24525次返回成功,0次返回失敗

當併發1000時:
webbench -c 1000 -t 60 http://test.domain.com/phpinfo.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://test.domain.com/phpinfo.php
1000 clients, running 60 sec.

Speed=24920 pages/min, 21037312 bytes/sec.
Requests: 24833 susceed, 87 failed.

當併發1000時,已經顯示有87個連線failed了,說明超負荷了。

備註:
1、壓力測試工作應該放到產品上線之前進行
2、測試時儘量跨公網模擬正式環境進行
3、測試時併發應當由小逐漸加大,比如併發100時觀察一下網站負載是多少、開啟是否流程,併發200時又是多少、網站開啟緩慢時併發是多少、網站打不開時併發又是多少