explaingit

mcollina/autocannon

8,439JavaScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

A Node.js tool that stress-tests web servers by firing thousands of requests and reporting back on speed, latency percentiles, and total throughput.

Mindmap

mindmap
  root((autocannon))
    What It Does
      Load test servers
      Measure latency
      Report throughput
    Usage Modes
      CLI command
      Library import
      HAR file replay
    Output Metrics
      Requests per second
      Latency percentiles
      JSON export
    Options
      Connection count
      Test duration
      Custom headers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Benchmark a REST API endpoint to find how many requests per second it handles before slowing down.

USE CASE 2

Automate performance checks in CI by importing autocannon as a library and failing if latency exceeds a threshold.

USE CASE 3

Replay recorded browser sessions from a HAR file to simulate realistic user traffic against a staging server.

USE CASE 4

Compare server performance before and after a code change by running timed load tests and diffing the JSON output.

Tech stack

JavaScriptNode.js

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

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.

Copy-paste prompts

Prompt 1
Run autocannon against my local server at http://localhost:3000 with 50 connections for 20 seconds and explain every number in the output table.
Prompt 2
Write a Node.js script that imports autocannon programmatically, runs a POST request benchmark with a JSON body, and throws an error if p99 latency exceeds 200ms.
Prompt 3
How do I use autocannon to replay a HAR file exported from Chrome DevTools against my staging API?
Prompt 4
Show me how to configure autocannon with a warmup period and then run the real measurement so server startup time does not skew my results.
Open on GitHub → Explain another repo

← mcollina on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.