压力测试工具

2016-07-04

webbench

webbench是Linux下的一个网站压力测试工具,最多可以模拟3万个并发连接去测试网站的负载能力。

下载地址:http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz 解压后不到50K

安装

#tar zxvf webbench-1.5.tar.gz
#cd webbench-1.5
#make && make install

会在当前目录生成webbench可执行文件,直接可以使用了

用法:

webbench -c 并发数 -t 运行测试时间 URL

如:

webbench -c 5000 -t 120 http://www.163.com

AB

1.安装

apt-get install apache2-utils

2.使用

ab -n10000 -c9000 http://malu.me/

说明:

-n 代表请求数,-c 代表并发数

返回结果说明:

This is ApacheBench, Version 2.3 <$Revision: 1528965 $>       #apache的版本信息 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /
Document Length:        0 bytes   #页面长度

Concurrency Level:      1000      #并发数 
Time taken for tests:   37.545 seconds   #共使用了多少时间 
Complete requests:      100000           #请求数 
Failed requests:        100000           #失败请求 
   (Connect: 0, Receive: 0, Length: 99712, Exceptions: 288)
Non-2xx responses:      99712
Total transferred:      33403520 bytes   #总共传输字节数,包含http的头信息等 
HTML transferred:       17649024 bytes   #html字节数,实际的页面传递字节数 
Requests per second:    2663.46 [#/sec] (mean)  #每秒多少请求,这个是非常重要的参数数值,服务器的吞吐量 
Time per request:       375.451 [ms] (mean)     #用户平均请求等待时间 
Time per request:       0.375 [ms] (mean, across all concurrent requests) #服务器平均处理时间,也就是服务器吞吐量的倒数 
Transfer rate:          868.84 [Kbytes/sec] received  #每秒获取的数据长度

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       12  178 109.6    184    1185
Processing:    21  196  44.4    196     315
Waiting:        0  146  41.9    136     274
Total:         87  374 116.6    382    1448

Percentage of the requests served within a certain time (ms)
  50%    382    # 50%的请求在382ms内返回 
  66%    388    # 66%的请求在388ms内返回 
  75%    395
  80%    400
  90%    409
  95%    452
  98%    474
  99%   1187
 100%   1448 (longest request)

3.参数使用说明

Usage: ab [options] [http[s]://]hostname[:port]/path
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.
    -h              Display usage information (this message)
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol
                    (SSL3, TLS1, TLS1.1, TLS1.2 or ALL)