# API Perf Autocannon

> Analyzes API latency distribution and connection behavior with autocannon, artillery quick mode, and request-level timing to separate network from application cost. Use when working with autocannon, artillery quick or when the user mentions autocannon, artillery quick.

- Skill: `opknock/api-perf-autocannon` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-perf-autocannon`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-perf-autocannon/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-perf-autocannon

---


Analyzes API latency distribution and connection behavior with autocannon, artillery quick mode, and request-level timing to separate network from application cost.

## Agentic Workflow: Read -> Reason -> Act (api-perf-autocannon)

You are **Api Perf Autocannon** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — backend context for `api-perf-autocannon`
- Domain: Analyzes API latency distribution and connection behavior with autocannon, artillery quick mode, and request-level timing to separate network from application cost.
- **autocannon**: Run pipelined HTTP benchmarks with full statistics — `npx autocannon -c 20 -d 30 -p 1 http://localhost:3000/`
- **artillery-quick**: Use artillery quick for ad-hoc load scenarios — `npx artillery quick -d 30 -r 20 http://localhost:3000/api`
- Check `knowledge` and `prerequisites: node.js, python, redis, k6`

### 2. Reason — think for `api-perf-autocannon`
- For `autocannon`: Run pipelined HTTP benchmarks with full statistics — decide which checks to run
- For `artillery-quick`: Use artillery quick for ad-hoc load scenarios — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-perf-autocannon` tools
- Tools: `Glob`, `Grep`, `Read`, `Npx` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-perf-autocannon:318b82ef`

# API Perf v4 - Latency Analysis

Latency distribution analysis with autocannon.

## What This Skill Does
- Measures latency percentiles with pipelining control
- Produces JSON artifacts for trend tracking
- Drives ad-hoc loads with artillery quick

## When to Use
- Verifying latency improvements after a fix
- Comparing request sizes and connection reuse
- Ad-hoc load checks without writing scripts

## Real Commands

```bash
npx autocannon -c 20 -d 30 -p 1 http://localhost:3000/
npx autocannon --json http://localhost:3000/ > results.json
npx artillery quick -d 30 -r 20 http://localhost:3000/api
```

## Interpreting Output
- avg/max: central and worst-case latency
- p1-p99: full distribution shape
- errors: connection and timeout failures
- requests/sec: achieved throughput

## Testing
- Repeat runs 3x and compare medians
- Vary payload size to expose serialization cost
- Test HTTP/1.1 vs HTTP/2 if both available

## Best Practices
- Keep -p 1 for mobile-like latency measurements
- Persist JSON outputs per build for regression charts
- Correlate latency shifts with deploy timestamps

## Capabilities

### autocannon
Run pipelined HTTP benchmarks with full statistics

**Parameters:**
- `connections` (integer): Number of concurrent connections
- `duration` (integer): Duration in seconds
- `pipelining` (integer): Pipelined requests per connection

**Commands:**
- `npx autocannon -c 20 -d 30 -p 1 http://localhost:3000/`
- `npx autocannon -c 10 -d 20 -m POST -b '{"a":1}' -H 'Content-Type=application/json' http://localhost:3000/api`
- `npx autocannon -c 20 -d 30 --json http://localhost:3000/ > results.json`
- `npx autocannon --renderStatusCodes -c 20 -d 10 http://localhost:3000/`

**Examples:**
- autocannon -p 1 disables pipelining for realistic latency
- --json emits machine-readable results for charts
- --renderStatusCodes shows the status code mix

### artillery-quick
Use artillery quick for ad-hoc load scenarios

**Commands:**
- `npx artillery quick -d 30 -r 20 http://localhost:3000/api`
- `npx artillery quick --count 50 --num 20 http://localhost:8080/users`
- `npx artillery quick -d 60 -r 50 -o report.json http://localhost:3000/`

**Examples:**
- -cli --help
- -api --help

## References
- [autocannon GitHub](https://github.com/mcollina/autocannon)
- [Artillery Quick Docs](https://www.artillery.io/docs/guides/getting-started/overview)

