0.0.3 • Published 6 years ago
multicannon v0.0.3
Install
npm i multicannonUsage
multicannon = require('multicannon');API
multicannon(opts, auth)
Start multicannon against the given target.
- opts: Array of configuration options for the multicannon instance. This can have the following attributes. REQUIRED.- url: The given target. Can be http or https. REQUIRED.
- socketPath: A path to a Unix Domain Socket or a Windows Named Pipe. A- urlis still required in order to send the correct Host header and path. OPTIONAL.
- connections: The number of concurrent connections. OPTIONAL default:- 10.
- duration: The number of seconds to run the multicannon. Can be a timestring. OPTIONAL default:- 10.
- amount: A- Numberstating the amount of requests to make before ending the test. This overrides duration and takes precedence, so the test won't end until the amount of requests needed to be completed are completed. OPTIONAL.
- timeout: The number of seconds to wait for a response before . OPTIONAL default:- 10.
- pipelining: The number of pipelined requests for each connection. Will cause the- ClientAPI to throw when greater than 1. OPTIONAL default:- 1.
- bailout: The threshold of the number of errors when making the requests to the server before this instance bail's out. This instance will take all existing results so far and aggregate them into the results. If none passed here, the instance will ignore errors and never bail out. OPTIONAL default:- undefined.
- method: The http method to use. OPTIONAL- default: 'GET'.
- title: A- Stringto be added to the results for identification. OPTIONAL default:- undefined.
- body: A- Stringor a- Buffercontaining the body of the request. Insert one or more randomly generated IDs into the body by including- [<id>]where the randomly generated ID should be inserted (Must also set idReplacement to true). This can be useful in soak testing POST endpoints where one or more fields must be unique. Leave undefined for an empty body. OPTIONAL default:- undefined.
- headers: An- Objectcontaining the headers of the request. OPTIONAL default:- {}.
- setupClient: A- Functionwhich will be passed the- Clientobject for each connection to be made. This can be used to customise each individual connection headers and body using the API shown below. The changes you make to the client in this function will take precedence over the default- bodyand- headersyou pass in here. There is an example of this in the samples folder. OPTIONAL default:- function noop () {}.
- maxConnectionRequests: A- Numberstating the max requests to make per connection.- amounttakes precedence if both are set. OPTIONAL
- maxOverallRequests: A- Numberstating the max requests to make overall. Can't be less than- connections.- maxConnectionRequeststakes precedence if both are set. OPTIONAL
- connectionRate: A- Numberstating the rate of requests to make per second from each individual connection. No rate limiting by default. OPTIONAL
- overallRate: A- Numberstating the rate of requests to make per second from all connections.- connectionRatetakes precedence if both are set. No rate limiting by default. OPTIONAL
- reconnectRate: A- Numberwhich makes the individual connections disconnect and reconnect to the server whenever it has sent that number of requests. OPTIONAL
- requests: An- Arrayof- Objects which represents the sequence of requests to make while benchmarking. Can be used in conjunction with the- body,- headersand- methodparams above. The- Objects in this array can have- body,- headers,- method, or- pathattributes, which overwrite those that are passed in this- optsobject. Therefore, the ones in this (- opts) object take precedence and should be viewed as defaults. Check the samples folder for an example of how this might be used. OPTIONAL.
- idReplacement: A- Booleanwhich enables the replacement of- [<id>]tags within the request body with a randomly generated ID, allowing for unique fields to be sent with requests. Check out an example of programmatic usage can be found in the samples. OPTIONAL default:- false
- forever: A- Booleanwhich allows you to setup an instance of multicannon that restarts indefinitely after emiting results with the- doneevent. Useful for efficiently restarting your instance. To stop running forever, you must cause a- SIGINTor call the- .stop()function on your instance. OPTIONAL default:- false
- servername: A- Stringidentifying the server name for the SNI (Server Name Indication) TLS extension. OPTIONAL default:- undefined.
- excludeErrorStats: A- Booleanwhich allows you to disable tracking non 2xx code responses in latency and bytes per second calculations. OPTIONAL default:- false.
 
- auth: authorization 'login:pass'
Example that just prints the table of results on completion:
const multicannon = require('multicannon');
const URLArr = [
    {
        url: 'http://localhost:3000/login',
        connections: 10,
        duration: 10
    },
    {
        url: 'http://localhost:3000/,
        connections: 10,
        duration: 10
    }
]
multicannon(URLArr, 'login:pass');