压力测试工具:ab,webbench

7月 6, 2008 – 8:00 下午

为了比较网站或者服务器的性能少不了压力测试工具。最受欢迎的是ab测试工具。ab测试工具随apache打包发布,所有应用起来十分方便。而webbench用起来更加的简单,参数很少简单易懂.

1. ab
根目录: 在apache的根目录下面。
测试例子: ab -n 10000 -c 100 -t 10 http://www.test.com/
参数: -n 表示请求总数, -c 表示并发数. -t 表示请求时间限制

  1. Usage: ab [options] [http[s]://]hostname[:port]/path
  2. Options are:
  3.     -n requests     Number of requests to perform
  4.     -c concurrency  Number of multiple requests to make
  5.     -t timelimit    Seconds to max. wait for responses
  6.     -p postfile     File containing data to POST
  7.     -T content-type Content-type header for POSTing
  8.     -v verbosity    How much troubleshooting info to print
  9.     -w              Print out results in HTML tables
  10.     -i              Use HEAD instead of GET
  11.     -x attributes   String to insert as table attributes
  12.     -y attributes   String to insert as tr attributes
  13.     -z attributes   String to insert as td or th attributes
  14.     -C attribute    Add cookie, eg. 'Apache=1234. (repeatable)
  15.     -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
  16.                     Inserted after all normal header lines. (repeatable)
  17.     -A attribute    Add Basic WWW Authentication, the attributes
  18.                     are a colon separated username and password.
  19.     -P attribute    Add Basic Proxy Authentication, the attributes
  20.                     are a colon separated username and password.
  21.     -X proxy:port   Proxyserver and port number to use
  22.     -V              Print version number and exit
  23.     -k              Use HTTP KeepAlive feature
  24.     -d              Do not show percentiles served table.
  25.     -S              Do not show confidence estimators and warnings.
  26.     -g filename     Output collected data to gnuplot format file.
  27.     -e filename     Output CSV file with percentages served
  28.     -h              Display usage information (this message)
  29.     -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
  30.     -f protocol     Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)

2.webbench
1)安装:

  1. wget http://www.guogoul.com/wp-content/uploads/2008/07/webbench-15tar.gz
  2. tar -xvvzf webbench-1.5.tar.gz
  3. cd webbench-1.5/
  4. make
  5. sudo make install
  6. 安装完毕!

2)例子: webbench -t 10 -c 1000 http://home.ucenter/
参数说明: -t 运行时间。 -c并发数。
3)参数:

  1. webbench [option]... URL
  2.   -f|--force               Don't wait for reply from server.
  3.   -r|--reload              Send reload request - Pragma: no-cache.
  4.   -t|--time <sec>          Run benchmark for <sec> seconds. Default 30.
  5.   -p|--proxy <server:port> Use proxy server for request.
  6.   -c|--clients <n>         Run <n> HTTP clients at once. Default one.
  7.   -9|--http09              Use HTTP/0.9 style requests.
  8.   -1|--http10              Use HTTP/1.0 protocol.
  9.   -2|--http11              Use HTTP/1.1 protocol.
  10.   --get                    Use GET request method.
  11.   --head                   Use HEAD request method.
  12.   --options                Use OPTIONS request method.
  13.   --trace                  Use TRACE request method.
  14.   -?|-h|--help             This information.
  15.   -V|--version             Display program version.

4) 结果;
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://home.ucenter/
1000 clients, running 10 sec.

Speed=80502 pages/min, 287123 bytes/sec.
Requests: 13417 susceed, 0 failed.

Post a Comment