autocannon
fast HTTP/1.1 benchmarking tool written in Node.js
A Node.js tool that stress-tests web servers by firing thousands of requests and reporting back on speed, latency percentiles, and total throughput.
Autocannon is a command-line tool for testing how fast a web server can handle incoming requests. You point it at a web address and it fires a large number of requests at that server for a set amount of time, then reports back on how the server performed. The results show things like how many requests per second the server handled, how long each request took, and how those times were distributed across the test period.
The tool is written in JavaScript and runs on Node.js, which is a common runtime for JavaScript outside of a browser. You install it through npm, the standard package manager for Node.js projects. Once installed you can run it from the terminal with a URL and a handful of options, or you can import it as a library into your own JavaScript code if you want to run benchmarks programmatically.
The main options let you control how many connections to open at once, how long to run the test, and how many requests to send per connection before moving on. You can also set a request body, custom headers, or an HTTP method like POST or PUT if you need to test endpoints that do more than just return a page. There is support for replaying recorded HTTP sessions from HAR files, which are snapshot files some browsers and developer tools can export. A warmup option lets the server reach a stable state before measurements begin, which can produce more realistic numbers.
The output is a table showing latency percentiles (how long the slowest 2.5%, median, and 97.5% of requests took), requests per second at the 1st through 97.5th percentile, and total throughput. All the raw numbers can also be printed as JSON if you want to feed them into another tool.
The README notes that on the author's machine autocannon generates higher load than comparable tools. It also includes a discussion of coordinated omission, a statistical problem that affects many benchmarking tools when servers are slow. The full README is longer than what was shown.
Where it fits
- Benchmark a REST API endpoint to find how many requests per second it handles before slowing down.
- Automate performance checks in CI by importing autocannon as a library and failing if latency exceeds a threshold.
- Replay recorded browser sessions from a HAR file to simulate realistic user traffic against a staging server.
- Compare server performance before and after a code change by running timed load tests and diffing the JSON output.