天天看點

ubuntu 14.04 LTS 安裝webbentch壓力測試工具

最近在做 壓力測試工具,除了apache的ab測試工具外,發現webbentch工具也不錯,這裡簡單介紹下這兩個工具。

一、webbentch安裝:

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

如果沒有安裝ctags,則安裝的時候會報錯。ctags的安裝:

apt-get install ctags

或者按照下面的步驟進行手動安裝:

wgethttp://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz

tarzxvfctags-5.8.tar.gz

cdctags-5.8

./configure

make &&makeinstall

二、webbentch使用:

測試原理:指定用戶端的并發數和執行時間,檢視伺服器發出的請求中susceed的個數和failed的個數

使用指令:webbentch -c 10000 -t 60 http://xx.xx.xx.156:8082/index.html

-c: 發起請求的用戶端數,也就是我們所說的并發數

-t:執行時間長度

執行結果如下:

Webbench - Simple Web Benchmark 1.5

Requests: 1033020 susceed, 5 failed.

Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://10.103.13.156:8082/index.html

10000 clients, running 60 sec.

Speed=1033025 pages/min, 3856600 bytes/sec.

Requests: 1033020 susceed, 5 failed.

三、apache的ab使用:

測試原理:指定用戶端的并發數和請求總量,計算伺服器每秒可以處理的請求數和每個請求響應的時間

使用指令:ab -c 10000 -n 80000 http://xx.xx.xx.156:8082/index.html

-c : 發起請求的用戶端數,也就是我們所說的并發數

-n:發起的總請求數

執行結果如下:

需要關心的幾個參數:Requests per second、Time per request

This is ApacheBench, Version 2.3 <$Revision: 1528965 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.103.13.156 (be patient)

Completed 8000 requests

Completed 16000 requests

Completed 24000 requests

Completed 32000 requests

Completed 40000 requests

Completed 48000 requests

Completed 56000 requests

Completed 64000 requests

Completed 72000 requests

Completed 80000 requests

Finished 80000 requests

Server Software: nginx //web伺服器

Server Hostname: xx.xx.xx.156 //web伺服器位址

Server Port: 8082 //web伺服器端口

Document Path: /index.html //請求位址

Document Length: 2 bytes //傳回的資料長度

Concurrency Level: 10000 //設定的并發數,就是-c設定的值

Time taken for tests: 13.691 seconds //所有請求執行完成所耗費的時間

Complete requests: 80000 //完成的請求數

Failed requests: 0 //失敗的請求數

Total transferred: 17920000 bytes //傳遞資料的大小,包括header的資訊

HTML transferred: 160000 bytes //傳遞的html的大小,這裡的數字等于 (Document Length) * (Complete requests)

Requests per second: 5843.27 [#/sec] (mean) //美妙的請求數,也就是我們伺服器可以承受的實際并發數,即通常所受的rps

Time per request: 1711.371 [ms] (mean) //每個請求的響應時間,mean表示是平均值

Time per request: 0.171 [ms] (mean, across all concurrent requests) //每個請求的時間,等于 (Time taken for tests * 1000ms) / Complete requests

Transfer rate: 1278.22 [Kbytes/sec] received //每秒傳輸的資料量,可以計算是否是帶寬的影響

Connection Times (ms) //時間的統計

min mean[+/-sd] median max

Connect: 2 156 486.3 18 4700

Processing: 12 240 920.8 19 12024

Waiting: 12 240 920.8 18 12024

Total: 29 396 1098.9 37 13050

Percentage of the requests served within a certain time (ms)

50% 37 //37毫秒響應了37%的請求

66% 45 //45毫秒響應了66%的請求

75% 143 //143毫秒響應了75%的請求,下面的以此類推

80% 258

90% 1035

95% 3034

98% 3702

99% 6029

100% 13050 (longest request)

三、注意事項:

在使用webbentch和apache的ab進行壓力測試的時候,如果測試的url位址中有多個參數,需要對url中的"&"符号進行轉義,輸入“\&”即可;把"&"=>"%26"是沒有效果的。

如url為 http://xx.xx.xx.156:8080/info.php?p1=v1&p2=v2&p3=v3

轉換後 http://xx.xx.xx.156:8080/info.php?p1=v1\&p2=v2\&p3=v3