# API Perf Wrk

> Benchmarks APIs with wrk, hey, and ApacheBench: throughput, latency percentiles, connection concurrency, and POST payload testing. Use when working with wrk, hey ab or when the user mentions wrk, hey ab.

- Skill: `opknock/api-perf-wrk` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-perf-wrk`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-perf-wrk/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-wrk

---


Benchmarks APIs with wrk, hey, and ApacheBench: throughput, latency percentiles, connection concurrency, and POST payload testing.

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

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

### 1. Read — backend context for `api-perf-wrk`
- Domain: Benchmarks APIs with wrk, hey, and ApacheBench: throughput, latency percentiles, connection concurrency, and POST payload testing.
- **wrk**: Run thread-based HTTP benchmarks with latency histograms — `wrk -t4 -c100 -d30s http://localhost:3000/api`
- **hey-ab**: Compare with hey and ApacheBench for POST and header testing — `hey -n 10000 -c 100 -m POST -H 'Content-Type: application/json' -d '{"q":"test"}`
- Check `knowledge` and `prerequisites: node.js, python, redis, k6`

### 2. Reason — think for `api-perf-wrk`
- For `wrk`: Run thread-based HTTP benchmarks with latency histograms — decide which checks to run
- For `hey-ab`: Compare with hey and ApacheBench for POST and header testing — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-perf-wrk` tools
- Tools: `Glob`, `Grep`, `Read`, `Wrk`, `Hey` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-perf-wrk:519bb419`

# API Perf v3 - Benchmarking

Raw HTTP benchmarking with wrk/hey/ab.

## What This Skill Does
- Measures requests/sec and latency percentiles
- Drives concurrent connections and POST bodies
- Compares framework and config changes quickly

## When to Use
- Quick A/B of a config flag
- Validating a framework or runtime change
- Establishing a throughput baseline

## Real Commands

```bash
wrk -t4 -c100 -d30s --latency http://localhost:3000/api
hey -n 10000 -c 100 -m POST -H 'Content-Type: application/json' -d '{"q":"test"}' http://localhost:3000/search
ab -n 5000 -c 50 -p post.json -T application/json http://localhost:3000/api
```

## Reading Results
- Requests/sec: throughput ceiling
- Latency Std Dev: jitter in responses
- Non-2xx responses: capacity-induced failures

## Testing
- Warm up with a short run before measuring
- Keep connection counts consistent between A/B runs
- Compare percentile curves, not just averages

## Best Practices
- Run benchmarks on dedicated machines to avoid noise
- Match benchmark traffic shape to production traffic
- Beware keep-alive (-k) inflating throughput on ab

## Capabilities

### wrk
Run thread-based HTTP benchmarks with latency histograms

**Parameters:**
- `threads` (integer): Number of threads (-t)
- `connections` (integer): Open connections (-c)
- `duration` (string): Benchmark duration like 30s

**Commands:**
- `wrk -t4 -c100 -d30s http://localhost:3000/api`
- `wrk -t2 -c50 -d20s --latency http://localhost:3000/api`
- `wrk -s post.lua -t4 -c50 -d30s http://localhost:3000/api`

**Examples:**
- wrk -t4 -c100 -d30s uses 4 threads and 100 connections for 30s
- --latency prints a full percentile distribution
- -s post.lua drives custom request bodies

### hey-ab
Compare with hey and ApacheBench for POST and header testing

**Commands:**
- `hey -n 10000 -c 100 -m POST -H 'Content-Type: application/json' -d '{"q":"test"}' http://localhost:3000/search`
- `hey -n 5000 -c 50 http://localhost:3000/api`
- `ab -n 5000 -c 50 -p post.json -T application/json http://localhost:3000/api`
- `ab -n 1000 -c 20 -k http://localhost:3000/api`

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

## References
- [wrk GitHub](https://github.com/wg/wrk)
- [ApacheBench Docs](https://httpd.apache.org/docs/2.4/programs/ab.html)

