Web服务器性能测试工具介绍

web性能测试工具

相关工具:webbench 、Apache bench

压力测试相关指标

  • 吞吐量(Requests per second, RPS),某个并发用户数下,单位时间内处理的请求数。

    注:RPS是基于并发用户数的。 R P S = C o m p l e t e   r e q u e s t s / T i m e   t a k e n   f o r   t e s t s RPS = Complete\ requests / Time\ taken\ for\ tests RPS=Complete requests/Time taken for tests

  • 并发连接数(The number of concurrent connections),指的是某个时刻服务器所接受的请求数目。

  • 并发用户数(The number of concurrent users, Concurrency Level)

    注:与并发连接数的区别,一个用户可能同时产生多个会话,即连接数。

  • 用户平均请求等待时间(Time per request) T i m e   p e r   r e q u e s t = T i m e   t a k e n   f o r   t e s t s / ( C o m p l e t e   r e q u e s t s / C o n c u r r e n c y   L e v e l ) Time \ per\ request = Time\ taken\ for\ tests / (Complete\ requests / Concurrency\ Level) Time per request=Time taken for tests/(Complete requests/Concurrency Level)

webbench

webbench的标准测试可以向我们展示服务器的两项内容:每秒钟相应请求数和每秒钟传输数据量。webbench不但能具有便准静态页面的测试能力,还能对动态页面(ASP,PHP,JAVA,CGI)进 行测试的能力。还有就是他支持对含有SSL的安全网站例如电子商务网站进行静态或动态的性能测试。Webbench最多可以模拟3万个并发连接去测试网站的负载能力。

http://home.tiscali.cz/~cz210552/webbench.html

  • webbench安装

    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
    
  • webbench使用

    webbench -c 1000 -t 60 URL
    webbench -c 并发数 -t 运行测试时间 URL
    
  • 命令行选项:

    短参 长参数 作用
    -f –force 不需要等待服务器响应
    -r –reload 发送重新加载请求
    -t –time 运行多长时间,单位:秒"
    -p –proxy server:port 使用代理服务器来发送请求
    -c –clients 创建多少个客户端,默认1个"
    -9 –http09 使用 HTTP/0.9
    -1 –http10 使用 HTTP/1.0 协议
    -2 –http11 使用 HTTP/1.1 协议
    –get 使用 GET请求方法
    –head 使用 HEAD请求方法
    –options 使用 OPTIONS请求方法
    –trace 使用 TRACE请求方法
    -?/-h –help 打印帮助信息
    -V –version 显示版本号

Apache bench

ab命令会创建很多的并发访问线程,模拟多个访问者同时对某一URL地址进行访问。

  • 命令行选项:

    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 10000 -c 100 URL

测试10000个请求,100并发的情况,对应的服务器配置,在VBOX下6G内存+4核CPU,在本机运行测试程序,测试结果如下

Server Software:
Server Hostname:        ****
Server Port:            ****

Document Path:          /
Document Length:        1131 bytes

Concurrency Level:      100
Time taken for tests:   119.681 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      11890000 bytes
HTML transferred:       11310000 bytes
Requests per second:    83.56 [#/sec] (mean)
Time per request:       1196.808 [ms] (mean)
Time per request:       11.968 [ms] (mean, across all concurrent requests)
Transfer rate:          97.02 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   11  97.6      1    1015
Processing:     6 1176 1295.6    546    7227
Waiting:        1  814 1063.4    212    5327
Total:          7 1187 1303.6   1101    7228

Percentage of the requests served within a certain time (ms)
  50%   1101
  66%   1263
  75%   1489
  80%   2234
  90%   3223
  95%   4226
  98%   5260
  99%   5336
 100%   7228 (longest request)

可以看到请求最长响应时间是7.2s,failed requests为0,RPS为83.56

你可能感兴趣的:(测试工具)