web應用 網站的壓力測試

首先咱們來介紹幾個經常使用的壓測工具,我也只瞭解這些,webbench/ab/jmeter 這三種工具,html

下面咱們來分別介紹一下這幾種工具的安裝和使用。linux

一、webbenchnginx

Webbench是有名的網站壓力測試工具,它是由Lionbridge公司(http://www.lionbridge.com)開發.它的幫助文件和文檔請到:www.webbench.com上查看.
Webbech能測試處在相同硬件上,不一樣服務的性能以及不一樣硬件上同一個服務的運行情況.webBech的標準測試能夠向咱們展現服務器的兩項 內容:每秒鐘相應請求數和每秒鐘傳輸數據量.webbench不但能具備便準靜態頁面的測試能力,還能對動態頁面(ASP,PHP,JAVA,CGI)進 行測試的能力.還有就是他支持對含有SSL的安全網站例如電子商務網站進行靜態或動態的性能測試.web

RedHat/CentOS下的編譯安裝
下載安裝包:wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gzapache

tar zxf webbench-1.5.tar.gz
cd webbench-1.5
make && make install

webbench使用windows

webbench --help  (查看命令幫助)
$: webbench -c 100 http://localhost:12345/test  
Webbench - Simple Web Benchmark 1.5  
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.  
  
Benchmarking: GET http://localhost:12345/test  
100 clients, running 30 sec.  
  
Speed=495888 pages/min, 586798 bytes/sec.  
Requests: 247944 susceed, 0 failed.

併發100個,運行30s,訪問請求所有成功,速度495888 pages/min, 586798 bytes/sec安全

 

二、ab服務器

下面是一種快速的方式。網絡

yum install httpd-tools併發

安裝完成後運行AB工具試試,出現下面的內容代表安裝成功。

ab: wrong number of arguments

使用:

#ab -c 1000 -n 4000 http://www.yousite.com/index.html  #具體到某頁面

-n後面的4000表明總共發出4000個請求;-c後面的1000表示採用1000個併發(模擬1000我的同時訪問),後面的網址表示測試的目標URL。

[root@Tomcat ab]# ab -c 1000 -n 4000 http://192.168.0.222/docs/manager-howto.html
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.0.222 (be patient)
Completed 400 requests
Completed 800 requests
Completed 1200 requests
Completed 1600 requests
Completed 2000 requests
Completed 2400 requests
Completed 2800 requests
Completed 3200 requests
Completed 3600 requests
Finished 4000 requests


Server Software:        nginx/1.4.3
Server Hostname:        192.168.0.222
Server Port:            80

Document Path:          /docs/manager-howto.html
Document Length:        73924 bytes

Concurrency Level:      1000
Time taken for tests:   0.875928 seconds
Complete requests:      4000
Failed requests:        0
Write errors:           0
Total transferred:      296732000 bytes
HTML transferred:       295696000 bytes
Requests per second:    4566.59 [#/sec] (mean)
#最重要的指標之一,至關於LR中的每秒事務數,後面括號中的mean表示這是一個平均值,越大抗壓越強
Time per request:       218.982 [ms] (mean) 
#最重要的指標之二,至關於LR中的平均事務響應時間,後面括號中的mean表示這是一個平均值
Time per request:       0.219 [ms] (mean, across all concurrent requests)
Transfer rate:          330822.86 [Kbytes/sec] received
#平均每秒網絡上的流量,吞吐量,越大抗壓越強

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   4.5      0      29
Processing:     1   17  14.5     17     653
Waiting:        0   17  14.5     17     653
Total:         15   18  15.2     17     674

Percentage of the requests served within a certain time (ms)
  50%     17
  66%     18
  75%     18
  80%     18
  90%     20
  95%     22
  98%     37
  99%     40
 100%    674 (longest request)

三、jmeter

jmeter這個工具既能夠在windows中運行也能夠在linux中運行,不過在windows中運行很容易達到瓶頸,線程開多了,本身機器扛不住了,沒法達到真正想要的壓測,不像linux cpu能夠飈到二三百。

下面介紹下jmeter在linux中的安裝和使用

(1)、下載,解壓

        http://jmeter.apache.org/download_jmeter.cgi

(2)、配置環境變量

        

vi /etc/profile

        添加以下兩行代碼

        export JMETER=/usr/local/jmeter/apache-jmeter-2.9 

        export PATH=${JMETER}/bin/:${PATH}

source /etc/profile

檢查是否配置成功:命令行輸入 jmeter -v 

若提示權限不夠,則 chmod 777 filename

運行前,先在Windows中jmeter圖形界面建立好測試計劃,而後放到linux系統文件目錄下usr/local/jmeter/testplan/linux_jmeter_test.jmx

#jmeter -n -t /usr/local/jmeter/testplan/linux_jmeter_test.jmx -l test_queryweb.jtl

執行完成,本身分析結果吧

 

 

http://blog.csdn.net/yangcs2009/article/details/31370091

相關文章
相關標籤/搜索