zoukankan      html  css  js  c++  java
  • ubuntu下 使用AB做压力测试

    1最近刚开始接触apache大数据下数据优化,讲一下apache 下ab压力测试工具。

    程序“ab”尚未安装。 您可以使用以下命令安装:

    apt-get install apache2-utils   

     以下是ab --help

    sage: 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)
    -n :总共的请求执行数,缺省是1; -c: 并发数,缺省是1; -t:测试所进行的总时间,秒为单位,缺省50000s -p:POST时的数据文件 -w: 以HTML表的格式输出结果  

    以下为执行    ab -n 5000 -c 200 http://localhost/test.php   的结果:

    Benchmarking localhost (be patient)
    Completed 500 requests
    Completed 1000 requests
    Completed 1500 requests
    Completed 2000 requests
    Completed 2500 requests
    Completed 3000 requests
    Completed 3500 requests
    Completed 4000 requests
    Completed 4500 requests
    Completed 5000 requests
    Finished 5000 requests   //执行完的请求次数
    
    Server Software: Apache
    /2.4.3 //apache版本 Server Hostname: localhost //主机 Server Port: 80 //端口 Document Path: /test.php //路径 Document Length: 62492 bytes Concurrency Level: 200 Time taken for tests: 3.927 seconds //完成此次请求时间 Complete requests: 5000 //完成请求次数 Failed requests: 527 //失败的请求次数 (Connect: 0, Receive: 0, Length: 527, Exceptions: 0) Total transferred: 313289422 bytes //总共传输字节 HTML transferred: 312459422 bytes Requests per second: 1273.33 [#/sec] (mean) //每秒请求次数 Time per request: 157.069 [ms] (mean) //一次请求时间 Time per request: 0.785 [ms] (mean, across all concurrent requests) Transfer rate: 77914.14 [Kbytes/sec] received //传输速率 Connection Times (ms) min mean[+/-sd] median max Connect: 0 6 73.1 0 1001 Processing: 2 150 143.9 111 1626 Waiting: 2 137 135.3 103 1197 Total: 2 155 160.3 111 1626 Percentage of the requests served within a certain time (ms) 50% 111 66% 141 75% 168 80% 191 90% 310 95% 452 98% 673 99% 951 100% 1626 (longest request)
  • 相关阅读:
    day_15补充加总结
    Day_15 内置模块er
    sort 函数 与 sorted 函数区别
    python 代码风格------------PEP8规则
    python 返回值
    函数记忆 : startswith() 与 endswith
    RE模块使用
    正则表达式
    collections
    函数datetime
  • 原文地址:https://www.cnblogs.com/timelesszhuang/p/3951519.html
Copyright © 2011-2022 走看看