node.js 快速 HTTP/1.1 基准测试工具

・4 分钟阅读

  • 源代码名称: autocannon
  • 源代码网址: https://www.github.com/mcollina/autocannon
  • autocannon的文档
  • autocannon的源代码下载
  • Git URL:
    git://www.github.com/mcollina/autocannon.git
  • Git Clone代码到本地:
    git clone https://www.github.com/mcollina/autocannon
  • Subversion代码到本地:
    $ svn co --depth empty https://www.github.com/mcollina/autocannon
                              Checked out revision 1.
                              $ cd repo
                              $ svn up trunk
              
  • banner

    autocannon

    Join the chat at https://gitter.im/mcollina/autocannonTravis Build StatusAppveyor Build Status

    demo

    HTTP/1.1基准测试工具,用node编写,支持HTTP流和HTTPS。

    
    npm i autocannon -g
    
    
    
    

    或者,如果要使用API或作为依赖项:

    
    npm i autocannon --save
    
    
    
    

    用法

    命令行

    
    Usage: autocannon [opts] URL
    
    
    
    URL is any valid http or https url.
    
    
    
    Available options:
    
    
    
     -c/--connections NUM
    
    
     The number of concurrent connections to use. default: 10.
    
    
     -p/--pipelining NUM
    
    
     The number of pipelined requests to use. default: 1.
    
    
     -d/--duration SEC
    
    
     The number of seconds to run the autocannnon. default: 10.
    
    
     -a/--amount NUM
    
    
     The amount of requests to make before exiting the benchmark. If set, duration is ignored.
    
    
     -S/--socketPath
    
    
     A path to a Unix Domain Socket or a Windows Named Pipe. A URL is still required in order to send the correct Host header and path.
    
    
     -m/--method METHOD
    
    
     The http method to use. default: 'GET'.
    
    
     -t/--timeout NUM
    
    
     The number of seconds before timing out and resetting a connection. default: 10
    
    
     -T/--title TITLE
    
    
     The title to place in the results for identification.
    
    
     -b/--body BODY
    
    
     The body of the request.
    
    
     -i/--input FILE
    
    
     The body of the request.
    
    
     -H/--headers K=V
    
    
     The request headers.
    
    
     -B/--bailout NUM
    
    
     The number of failures before initiating a bailout.
    
    
     -M/--maxConnectionRequests NUM
    
    
     The max number of requests to make per connection to the server.
    
    
     -O/--maxOverallRequests NUM
    
    
     The max number of requests to make overall to the server.
    
    
     -r/--connectionRate NUM
    
    
     The max number of requests to make per second from an individual connection.
    
    
     -R/--overallRate NUM
    
    
     The max number of requests to make per second from an all connections.
    
    
     connection rate will take precedence if both are set.
    
    
     NOTE: if using rate limiting and a very large rate is entered which cannot be met,
    
    
     Autocannon will do as many requests as possible per second.
    
    
     -D/--reconnectRate NUM
    
    
     Some number of requests to make before resetting a connections connection to the
    
    
     server.
    
    
     -n/--no-progress
    
    
     Don't render the progress bar. default: false.
    
    
     -l/--latency
    
    
     Print all the latency data. default: false.
    
    
     -I/--idReplacement
    
    
     Enable replacement of [<id>] with a randomly generated ID within the request body. default: false.
    
    
     -j/--json
    
    
     Print the output as newline delimited json. This will cause the progress bar and results not to be rendered. default: false.
    
    
     -f/--forever
    
    
     Run the benchmark forever. Efficiently restarts the benchmark on completion. default: false.
    
    
     -s/--servername
    
    
     Server name for the SNI (Server Name Indication) TLS extension.
    
    
     -x/--excludeErrorStats
    
    
     Exclude error statistics (non 2xx http responses) from the final latency and bytes per second averages. default: false.
    
    
     -v/--version
    
    
     Print the version number.
    
    
     -h/--help
    
    
     Print this menu.
    
    
    
    

    以编程方式

    'use strict'constautocannon=require('autocannon')autocannon({
     url:'http://localhost:3000',
     connections:10, //default pipelining:1, // default duration:10// default}, console.log)
    讨论
    Fansisi profile image