autocannon is an HTTP/1.1 benchmarking tool for Node.js. You install it from npm, point it at a URL, and it opens a set of connections, for 10 seconds sends requests as fast as the server answers them, and prints latency percentiles and requests per second. It also has a JavaScript API, so a Node.js team can script request sequences and fail a CI build on the result.
This autocannon load testing tutorial runs version 9.0.0, released on 6 November 2026, against a small local API and shows the output it printed, including four behaviours worth knowing before you trust a number: how connections set the request rate, what pipelining does, why a slow endpoint can show 0 ms, and what the -R rate limit does to the latency percentiles.
Key Takeaways
- autocannon 9.0.0 (6 November 2026) is MIT-licensed and installs with
npm i -g autocannonor runs throughnpx autocannon. It speaks HTTP/1.1 only. - Without a rate limit, the request rate is connections divided by response time: 10 connections against a 25 ms endpoint sent 373 requests a second, and 100 connections sent 3,684.
- An endpoint slower than the 10-second timeout shows 0 ms at every percentile. Read the “errors (timeouts)” line under the tables.
- autocannon exits with code 0 even when 5% of responses are HTTP 500s. A short script around its API turns the result into a pass or fail.
- With
-R, autocannon’s coordinated omission correction uses a 1 ms interval, so the percentiles it prints are wrong: a 13 ms median for an endpoint that never answered in under 25 ms, and a 948 ms median during a slowdown where-Cmeasured 27 ms. Add-Cto every rate-limited run.
What is autocannon?
autocannon is an open-source HTTP/1.1 load generator written in JavaScript by Matteo Collina, published on npm under the MIT licence. It runs from the command line or as a Node.js module, keeps a fixed number of connections busy, and reports latency and throughput from HDR histograms. Its README says it was inspired by wrk and wrk2.
The current release is 9.0.0, published to npm on 6 November 2026. The project has no release notes for it. The changes merged that day update dependencies, move the project’s own tests and CI to Node.js 22 and 24, and replace Node.js’s deprecated url.parse() with the WHATWG URL API, so Node.js 24 no longer prints deprecation warnings. Two smaller fixes from April and May, fixed-length request IDs and a trailers event, are also in it. The GitHub repository has no v9.0.0 tag, but the npm package’s gitHead points at the “Bumped v9.0.0” commit on the master branch, and the author published it.
autocannon fits the same job as the wrk benchmark tool and hey: hammering one endpoint or a short sequence of requests to measure a server, from one machine. It is not a tool for modelling user journeys with think times and ramps; for that, see the load testing tools roundup.
How do you install autocannon?
Install autocannon globally from npm to get the autocannon command, or add it to a project when you want to call it from JavaScript. npx autocannon runs it without installing anything permanently. The package declares no Node.js engines range; its own CI now tests on Node.js 22 and 24.
npm i -g autocannon
autocannon --version
# or, inside a project that will use the API
npm i --save-dev autocannon
We installed 9.0.0 into a separate folder and ran it on Node.js 23.11.1; autocannon --version printed autocannon v9.0.0.
How do you run your first autocannon benchmark?
Give autocannon a URL. With no other options it opens 10 connections, keeps each one busy with one request at a time for 10 seconds, and prints two tables. Our test API’s product endpoint waits 25 ms before answering:
autocannon http://127.0.0.1:8099/api/items/7
Running 10s test @ http://127.0.0.1:8099/api/items/7
10 connections
┌─────────┬───────┬───────┬───────┬───────┬──────────┬────────┬───────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼───────┼───────┼───────┼───────┼──────────┼────────┼───────┤
│ Latency │ 25 ms │ 26 ms │ 36 ms │ 44 ms │ 27.44 ms │ 3.3 ms │ 61 ms │
└─────────┴───────┴───────┴───────┴───────┴──────────┴────────┴───────┘
┌───────────┬─────────┬─────────┬───────┬─────────┬───────┬─────────┬─────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────────┼─────────┼───────┼─────────┼───────┼─────────┼─────────┤
│ Req/Sec │ 343 │ 343 │ 358 │ 370 │ 358 │ 7.51 │ 343 │
├───────────┼─────────┼─────────┼───────┼─────────┼───────┼─────────┼─────────┤
│ Bytes/Sec │ 65.2 kB │ 65.2 kB │ 68 kB │ 70.3 kB │ 68 kB │ 1.43 kB │ 65.2 kB │
└───────────┴─────────┴─────────┴───────┴─────────┴───────┴─────────┴─────────┘
Req/Bytes counts sampled once per second.
# of samples: 10
4k requests in 10.02s, 680 kB read
The main options:
| Option | Default | What it does |
|---|---|---|
-c, --connections | 10 | Concurrent connections |
-d, --duration | 10 | Seconds to run |
-a, --amount | none | Stop after this many requests instead |
-p, --pipelining | 1 | Requests sent on a connection before waiting for responses |
-w, --workers | none | Worker threads |
-R, --overallRate | none | Cap on requests per second across all connections |
-t, --timeout | 10 | Seconds before a request times out |
-j, --json | off | Print the result as JSON |
How do you read autocannon output?
The first table is latency: the time from sending a request to receiving its response, at the 2.5th, 50th, 97.5th and 99th percentiles, plus the mean, standard deviation and maximum. The second table counts requests and bytes in each one-second sample, so its percentiles describe seconds, not requests. The last line gives the total.
In our run the median request took 26 ms and the 99th percentile 44 ms, against a server that waits 25 ms, so autocannon and the network added about a millisecond in the middle. The Req/Sec row says the slowest one-second sample had 343 requests and the median second 358. With 10 seconds there are only 10 samples, so the 1% and 2.5% columns are the same sample, as the README points out. Our guide to why percentiles beat averages explains why the tail columns matter more than the average.
-l prints the full list of latency percentiles, and -j prints the whole result as JSON, with p50, p75, p90, p97.5, p99, p99.9 and beyond for latency, plus counts for errors, timeouts and each status code.
Why does the number of connections set the request rate?
Each autocannon connection sends a request, waits for the response, and sends the next one, so the request rate is the number of connections divided by the response time. Ten connections against a 25 ms endpoint can never send much more than 400 requests a second, however fast the machine. To push harder you add connections, not duration.
| Separate runs against the 25 ms endpoint | Requests per second | Median latency |
|---|---|---|
-c 10 | 373 | 26 ms |
-c 100 | 3,684 | 26 ms |
-c 10 -p 10 | 3,721 | 26 ms |
That makes -c a concurrency setting, not a user count. A real user waits seconds between clicks; an autocannon connection waits for nothing. One hundred connections here produced the traffic of thousands of real visitors, which is why our guide to calculating concurrent users starts from request rate rather than from a head count.
What does pipelining (-p) do to the results?
-p 10 sends 10 requests down a connection before waiting for any response, which is HTTP/1.1 pipelining. On our 25 ms endpoint it had the same effect as ten times the connections: 3,721 requests a second from 10 connections. On an endpoint that answers instantly, 100 connections went from 68,959 requests a second to 164,274 with -p 10.
The second number is real for the server, and useless for a capacity plan: browsers do not pipeline HTTP/1.1 requests, so no real visitor produces that traffic. Use pipelining to find the ceiling of a server’s request parsing, and leave it at the default of 1 for anything you will compare with production traffic. The README’s comparison says wrk cannot pipeline; wrk can, but only through a Lua script (its repository ships scripts/pipeline.lua).
How do you send POST requests and headers with autocannon?
Set the method with -m, add headers with -H (once per header), and pass the body with -b, or -i to read it from a file. -I replaces [<id>] in the body with a random ID, so each request can carry a unique value. Apart from that ID, every request sends the same body; for different data per request, use the API.
autocannon -m POST \
-H 'content-type=application/json' \
-H 'authorization=Bearer tok-demo' \
-b '{"id": 7}' \
http://127.0.0.1:8099/api/cart
Headers use name=value, not the name: value form curl uses. A JSON body with no content-type header is sent anyway, and some frameworks then refuse to parse it, which the help text warns about.
How do you script a login and reuse the token?
Use autocannon’s JavaScript API with a requests array. Each connection walks the array in order, and a context object carries values between steps: onResponse reads the token from the login response, and setupRequest adds it to the next request. When the array ends, the connection starts again from the first request, so the token lasts one pass through the array.
const autocannon = require('autocannon')
const instance = autocannon({
url: 'http://127.0.0.1:8099',
connections: 20,
duration: 15,
requests: [
{
method: 'POST',
path: '/api/login',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ user: 'demo', password: 'secret' }),
onResponse: (status, body, context) => {
if (status === 200) context.token = JSON.parse(body).token
}
},
{ method: 'GET', path: '/api/items' },
{
method: 'POST',
path: '/api/cart',
setupRequest: (req, context) => ({
...req,
headers: { ...req.headers, 'content-type': 'application/json', authorization: `Bearer ${context.token}` },
body: JSON.stringify({ id: 7 })
})
}
]
}, (err, result) => {
if (err) throw err
console.log(result.statusCodeStats)
})
autocannon.track(instance, { renderProgressBar: false })
Our cart endpoint returns 401 without a valid token. In 15 seconds the script sent 76,630 cart requests, every one answered 201, with 153,281 responses of 200 for the login and list calls. Because the array restarts, the login runs once per loop, not once per connection. autocannon cannot skip a step, and it resets context each time the array starts again, so the token lasts one loop. To log in only once, fetch a token before the run and pass it in headers, or in initialContext, which is copied into every loop. With workers, setupRequest and onResponse must be file paths that export the function, not inline functions.
What goes wrong with -R and coordinated omission?
-R caps the overall request rate, and by default autocannon then “corrects” latencies for coordinated omission, the requests a slowed server kept it from sending. In 9.0.0 the correction uses the wrong interval: it records every response as if requests were due once a millisecond, adding one invented latency value per millisecond of each response. The percentiles that follow are wrong whether the server is fast or slow.
Coordinated omission is the error a closed-loop tool makes when the server slows down: each connection waits for its slow response, so the requests that should have been sent meanwhile are never sent and their delay is never measured. A correction adds the missing samples back. autocannon passes Math.ceil(1 / rate) as the expected interval (line 244 of lib/run.js), where rate is requests per second per connection and latencies are in milliseconds, so the interval comes out as 1 ms instead of 1,000 divided by the rate.
We ran 10 connections at -R 100 for 20 seconds against the steady 25 ms endpoint, with and without -C, which turns the correction off:
| 25 ms endpoint, 20 s | 2.5% | Median | 99% | Values in the histogram |
|---|---|---|---|---|
-c 10 -R 100 (correction on) | 1 ms | 13 ms | 26 ms | 51,426 |
-c 10 -R 100 -C | 25 ms | 26 ms | 31 ms | 2,000 |
-c 10, no rate limit | 25 ms | 26 ms | 29 ms | 7,588 |
The endpoint never answers in under 25 ms, yet the corrected run reports a 2.5th percentile of 1 ms: each 25 ms response added 24 invented values from 24 ms down to 1 ms. When the server slows down, the same rule adds about 2,000 values for every 2-second response. We made the endpoint take 2 seconds for 20 seconds of a 60-second run at -R 100 with 100 connections. With the correction, autocannon reported a median of 948 ms; with -C it reported 27 ms and a 90th percentile of 2,002 ms, which matches what happened.
Three more things decide what -R actually sends:
- Connections still wait. During the slowdown the server received 100 requests one second and none the next, about 50 a second: each connection is allowed one request a second and waits 2 seconds for its answer.
- Extra connections are dropped. With
-c 300 -R 100, autocannon lowered the connection count to 100 (when the rate is below-c,run.jssets connections to the rate), and the slowdown played out exactly as with-c 100. - The rate applies per worker.
-w 2 -R 100sent 199.6 requests a second. The README notes this; it is easy to miss.
We found no issue about the interval in the autocannon repository as of November 2026; the correction dates from a 2020 pull request and is unchanged in 9.0.0 and on the master branch. Until it changes, add -C to every run that uses -R or its per-connection form -r, and use an open-model tool when you need a fixed arrival rate under slowdowns: the Vegeta tutorial shows one that keeps sending at the set rate.
Why does autocannon show 0 ms for a slow endpoint?
Because a request that times out records no latency. autocannon’s default timeout is 10 seconds; a request still waiting then counts as an error and a timeout, and is left out of the latency table. If every request times out, every percentile prints as 0 ms and the Req/Sec row as 0.
We pointed 5 connections at an endpoint that takes 12 seconds, for 25 seconds:
│ Latency │ 0 ms │ 0 ms │ 0 ms │ 0 ms │ 0 ms │ 0 ms │ 0 ms │
...
15 requests in 25.03s, 0 B read
10 errors (10 timeouts)
The other 5 requests were still waiting when the run ended. The only sign of the problem is the last line. Raise -t above your slowest expected response, and read the errors line on every run. The 12-second run also exited with code 0.
How do you fail a CI build with autocannon?
Wrap autocannon’s JavaScript API in a short script that sets the exit code, because autocannon has no thresholds and exits with code 0 whatever the results. Against an endpoint that returns HTTP 500 for 5% of requests, it reported 4.96% non-2xx responses and exited with 0. -B (bailout) does not help with server errors either; it counts connection errors, timeouts and -E body mismatches, not status codes, and a run with -B 50 against the same endpoint finished normally.
This script fails the run on a p99 or error-rate limit:
const autocannon = require('autocannon')
const url = process.argv[2]
const limits = { p99: 100, errorRate: 0.01 } // milliseconds, share of requests
autocannon({ url, connections: 20, duration: 15 }, (err, result) => {
if (err) throw err
const done = result.requests.total + result.errors
const errorRate = (result.non2xx + result.errors) / Math.max(done, 1)
const failed = []
if (result.latency.p99 > limits.p99) failed.push(`p99 ${result.latency.p99} ms > ${limits.p99} ms`)
if (errorRate > limits.errorRate) failed.push(`errors ${(errorRate * 100).toFixed(2)}% > ${limits.errorRate * 100}%`)
if (result.requests.total === 0) failed.push('no successful requests')
console.log(failed.length ? `FAIL: ${failed.join('; ')}` : `PASS: p99 ${result.latency.p99} ms, errors ${(errorRate * 100).toFixed(2)}%`)
process.exitCode = failed.length ? 1 : 0
})
| Target | Script output | Exit code |
|---|---|---|
| 25 ms endpoint | PASS: p99 40 ms, errors 0.00% | 0 |
| 5% HTTP 500 | FAIL: errors 4.99% > 1% | 1 |
| 12-second endpoint | FAIL: errors 100.00% > 1%; no successful requests | 1 |
Count timeouts as failures, as this script does: result.errors includes them, and result.non2xx does not. For a server under test in the same job, --on-port starts it for you: autocannon --on-port /fast -- node server.js waited for our server to listen, ran the test and stopped the server again.
How much load can one autocannon process generate?
One autocannon process runs on one CPU core, which on our 10-core M1 Max laptop topped out at about 69,000 requests a second against an endpoint that answers instantly. The README calls autocannon CPU-bound and recommends wrk2 once it reaches 100% CPU. In our runs, -w (worker threads) was the way past one core.
/fast endpoint, 100 connections, 10 s | Best run | CPU cores used | CPU seconds per 1,000 requests | Memory |
|---|---|---|---|---|
| autocannon, one process | 69,066 req/s | 1.00 | 0.015 to 0.024 | 87 to 109 MB |
autocannon -w 4 | 128,646 req/s | 2.48 | 0.022 to 0.035 | 177 to 219 MB |
autocannon -p 10 | 164,274 req/s | 0.91 | 0.006 to 0.008 | 103 to 117 MB |
wrk -t4 | 147,824 req/s | 3.18 | 0.012 to 0.022 | 4 to 7 MB |
The single process stopped at about 69,000 requests a second in two separate runs, both at exactly one core. Per request it was not expensive: across three batches it used 0.015 to 0.024 CPU seconds per 1,000 requests, against 0.012 to 0.022 for wrk, and between 0.8 and 1.7 times wrk’s figure in the same batch, so the README’s “significantly more CPU than wrk” did not show consistently on this machine. The limit is the single core. Four worker threads lifted the best run to 128,646, using more CPU per request, and wrk reached 147,824 while holding a few megabytes of memory against autocannon’s hundred or more.
The laptop was running other work during these runs, and the same command swung from 5,620 to 69,066 requests a second between batches. Treat the rates as ceilings seen on one machine, and the CPU per request, which moved far less, as the comparison. When the autocannon process reaches 100% CPU, its numbers measure autocannon: add -w, or move to a tool written in a compiled language.
When is autocannon the wrong tool?
autocannon measures how fast a server answers a burst of requests from one machine. It is the wrong tool for testing how a site behaves for real users: it has no think times, no ramp-up stages, no geographic spread and no thresholds, and its rate limit is unreliable, as shown above. For those jobs a scripted load testing tool is the better fit.
If your Node.js team likes autocannon’s JavaScript API, k6 keeps the same language: our k6 checks guide shows its pass or fail thresholds, which autocannon lacks.
Running the same test from the cloud with LoadFocus
LoadFocus runs k6 and JMeter scripts, and tests built in the browser, from 25 cloud regions, so the load does not come from your own laptop or CI runner. k6 tests run with up to 20,000 concurrent virtual users depending on the plan, and on Pro and Enterprise plans a test can split its load across several regions. It does not run autocannon scripts.
An autocannon command is one URL with a method, headers and a body, which is a curl command in another form. The free curl to k6 converter turns that into a k6 script in the browser, which you can then run as a k6 load test in the cloud.
Frequently Asked Questions
Is autocannon better than wrk?
Neither is better overall: both measure one endpoint as fast as possible, and they differ in language and resource use. autocannon is a Node.js package with a JavaScript API, detailed latency percentiles and JSON output, which suits Node.js teams and CI scripts. wrk is a C binary that holds a few megabytes of memory and scripts in Lua. One autocannon process uses one CPU core, so it needs worker threads to approach wrk on a fast server.
What does the -c option mean in autocannon?
It sets the number of concurrent connections, 10 by default. Each connection sends one request, waits for the response and sends the next, so the request rate is the number of connections divided by the response time. Ten connections against a 25 ms endpoint sent 373 requests a second in our test; 100 connections sent 3,684.
Does autocannon support HTTP/2?
No. autocannon is an HTTP/1.1 client: its README describes it as an HTTP/1.1 benchmarking tool, and it writes requests to plain TCP or TLS sockets itself. To load test an HTTP/2 endpoint, use a tool that speaks HTTP/2, such as k6, which negotiates HTTP/2 over TLS automatically.
Is autocannon free?
Yes. autocannon is open source under the MIT licence and installs from npm at no cost. You pay only for the machine that runs it, and because one process uses one CPU core, a heavy test may need a machine with several cores and the workers option.
Why does autocannon report lower latency with -R?
Because its latency correction, which is on by default when you set a rate and is meant to account for requests a slowed server kept it from sending, assumes requests were due once a millisecond. In version 9.0.0 that adds invented low values for every response, so a 25 ms endpoint reported a 13 ms median in our test. During a slowdown the same rule pushes the median up instead. Adding the -C flag turns the correction off and reports the measured latencies.
Sources
- autocannon 9.0.0 package: registry.npmjs.org/autocannon (publish time 6 November 2026, MIT licence,
gitHead3774f486, publisher), and the installed package’s README and--help, November 2026. - Changes in 9.0.0: github.com/mcollina/autocannon pull requests #543 (update dependencies), #549 (replace deprecated URL parsing) and #550 (tests on node:test, CI on Node.js 22 and 24), merged 6 November 2026, and #540 (fixed-length IDs, April 2026) and #544 (trailers event, May 2026); repository tags and commit history, read 20 November 2026.
- Coordinated omission correction:
lib/run.jslines 33, 174 and 244 andlib/requestIterator.js(context reset) in autocannon 9.0.0 (unchanged on the master branch at commit aa55bd5, 16 November 2026, and in v8.0.0); pull request #274 (August 2020), which added it;recordSingleValueWithExpectedIntervalin hdr-histogram-js 3.0.1. Issue search for “coordinated omission”, “expected interval” and “ignoreCoordinatedOmission”, 20 November 2026. - Workers, per-worker rate limits, results object and limitations: autocannon README, sections “Workers”, “Results” and “Limitations”, version 9.0.0.
- wrk pipelining: github.com/wg/wrk,
scripts/pipeline.lua, November 2026. - LoadFocus k6 cloud runs, regions and virtual user limits: loadfocus.com/k6-load-testing and loadfocus.com/index.md; curl converter: loadfocus.com/curl-to-k6, read 20 November 2026.
- Test runs: autocannon 9.0.0 on Node.js 23.11.1 against a local Node.js test API (four worker processes; one process for the slowdown runs, which counted arrivals per second itself) on an Apple M1 Max with 10 cores, 20 November 2026. CPU and memory from
/usr/bin/time -l. The laptop carried other sessions’ work during the runs (load average from about 27 to over 180 where it was recorded), so compare runs within one test, not between tests; the maximum-rate table shows best runs and CPU time per request from three batches.