loadtest
HTTP and WebSocket load testing tool for Node.js
TLDR
SYNOPSIS
loadtest [options] url
DESCRIPTION
loadtest runs load tests against HTTP, HTTPS or WebSocket (ws://) URLs. The single-dash options are compatible with Apache ab, but options may also follow the URL. Unlike ab, --rps keeps a constant request rate regardless of how fast the server answers, which gives more realistic results for sustained load.At the end of the run it reports total requests, errors, requests per second, mean latency and latency percentiles (50%, 90%, 95%, 99%). It can also be used as a library from Node.js code and ships a testserver-loadtest command for measuring the tool's own limits.
PARAMETERS
-n, --maxRequests num
Number of requests to send. Default: no limit (runs until the time limit).-c, --concurrency num
Number of concurrent clients. Default: 10. Ignored when --rps is set.-t, --maxSeconds seconds
Maximum time to send requests. Default: 10, applies only if -n is not given.--rps, --requestsPerSecond num
Send a constant number of requests per second (integer). Not supported for WebSockets.-k, --keepalive
Use keep-alive connections.-m, --method method
HTTP method: GET, POST, PUT, DELETE or PATCH. Default: GET.-P, --postBody body
Send the string as the POST body.-A, --patchBody body
Send the string as the PATCH body.--data body
Body data for the method set with -m (not for GET).-p, --postFile file
POST the contents of a file; a .js file is imported and its default export generates each body.-u, --putFile file
PUT the contents of a file.-a, --patchFile file
PATCH the contents of a file.-T, --contentType type
Content-Type for the body. Default: text/plain.-H, --header header:value
Custom header; can be repeated.-C, --cookie name=value
Send a cookie; can be repeated.--cores num
Number of processes to run in parallel. Default: half the available CPUs.--timeout ms
Timeout for each request in milliseconds. Default: 0 (none).-R module.js
Use a custom request generator module.-s, --secureProtocol method
TLS method to use (e.g. TLSv12method).--insecure
Accept invalid and self-signed certificates.--cert file, --key file
Client certificate and key (used together).--tcp
Experimental: use raw TCP sockets for higher performance.--quiet
Do not show any messages.-V, --version
Show version and exit.
CAVEATS
Requires Node.js 16 or later for version 6+. Each process saturates a CPU at a few thousand requests per second; use --cores or a faster tool such as wrk or autocannon for higher loads. Since version 8 the defaults are -c 10 and -t 10; older versions defaulted to concurrency 1 and no time limit.
HISTORY
loadtest was created by Alex Fernández in 2013 and is distributed through npm.
