web页面与java websocket接口的压力测试

上一篇 / 下一篇  2022-01-10 11:03:00 / 个人分类:测试

对于网站开发,压力测试是少不了的。压力测试可以对网络,服务器,系统架构的优化程度进行检验。以便提前知道网站的负载能力,并未优化提供依据。
对于网站的压力测试,基本离不开下面两点的测试:web页面访问的压力测试和java接口的压力测试(我们接口是通过websocket实现)。
web页面访问压力测试工具可以使用apache自带的ab命令进行检测;java websocket接口的压力测试可以使用Jmeter+websocket插件进行检测。
ab安装与使用
一、下载软件
下载地址:http://de.apachehaus.com/downloads/httpd-2.4.17-x64.zip
二、进入软件路径
把下载的文件解压到后,用cmd指令进入”文件夹路径/Apache24/bin”
三、获取ab指令参数列表
执行“ab help”
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make at a time
    -t timelimit    Seconds to max. to spend on benchmarking
                    This implies -n 50000
    -s timeout      Seconds to max. wait for each response
                    Default is 30 seconds
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -B address      Address to bind to when making outgoing connections
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header to use for POST/PUT data, eg.
                    'application/x-www-form-urlencoded'
                    Default is 'text/plain'
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. 'Apache=1234'. (repeatable)
    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -q              Do not show progress when doing more than 150 requests
    -l              Accept variable document length (use this for dynamic pages)
 
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don't exit on socket receive errors.
    -m method       Method name
    -h              Display usage information (this message)
四、进行web压力测试
执行“ab -n 1000 -c
100 http://www.baidu.com/index.html”
五、报表结果
Server Software:        Apache/2.4.7Server Hostname:        www.3elearn.com.cnServer Port:            80
 Document Path:          /index.htmlDocument Length:        16300 bytes
 Concurrency Level:      100Time taken for tests:   26.931 secondsComplete requests:      1000Failed requests:        0Total transferred:      16573000 bytes
HTML transferred:       16300000 bytesRequests per second:    37.13 [#/sec] (mean)Time per request:       2693.147 [ms] (mean)Time per request:       26.931 [ms] (mean, across all concurrent requests)Transfer rate:          600.95 [Kbytes/sec] received
 Connection Times (ms)
              min  mean[+/-sd] median   maxConnect:        9   27   9.1     26      51Processing:    50 2532 466.3   2659    2740Waiting:       27 1325 769.3   1330    2649Total:         80 2559 466.1   2687    2776
 Percentage of the requests served within a certain time (ms)
  50%   2687
  66%   2704
  75%   2714
  80%   2718
  90%   2730
  95%   2739
  98%   2749
  99%   2754
 100%   2776 (longest request)
Jmeter安装与使用
一、载
下载地址:http://mirror.bit.edu.cn/apache//jmeter/binaries/apache-jmeter-2.13.zip
二、安装
解压文件夹,然后进入“apache-jmeter-2.13/bin/”
双击“jmeter.bat”启动软件
三、安装websokcet插件
Websocket插件下载:https://dl.dropboxusercontent.com/u/89045969/jmeter/ApacheJmeter_websocket-0.1.0-SNAPSHOT.jar
https://dl.dropboxusercontent.com/u/89045969/jmeter/ApacheJmeter_websocket-dist-0.1.0-SNAPSHOT.jar
把jar包复制到“jmeter安装路径/lib/ext/”
关闭jmeter再启动
四、使用
a)添加线程组?
在“测试计划”—“添加“——”Threads(users)”——“线程组”
b)添加websocket?
在“线程组”——“添加”——“sample”——“websocket sample”
c)添加结果树?
在“线程组”——“添加”——“监听器”——“查看结果树”

TAG:

 

评分:0

我来说两句

Open Toolbar