Skip to content
>_devvkit
$devvkit learn --librarie wrk-&-hey-guide

wrk & hey Guide

[benchmark][http][cli][latency]
Performance & Profiling
Install
# wrk
brew install wrk
sudo apt install wrk

# hey (Go)
brew install hey
# or: go install github.com/rakyll/hey@latest

wrk is a multithreaded HTTP benchmarking tool that uses a LuaJIT scripting engine for custom request generation. It's perfect for measuring raw throughput and latency distribution (latency, req/s, transfer rate) on a single endpoint.

hey (formerly boom) is built in Go and is simpler than wrk — it supports POST with body, custom headers, and HTTP/2 out of the box. Use it when you need to benchmark API endpoints with JSON payloads.

Both tools report latency percentiles (p50, p75, p90, p99, max), request rate, and error counts. For distributed load generation across multiple machines, use vegeta or k6 instead. The wrk2 fork adds constant throughput mode.

wrk Basics

wrk — basicSimple throughput test.
wrk -t12 -c400 -d30s http://localhost:8080
# -t: threads, -c: connections, -d: duration
wrk — keep-aliveDisable keep-alive.
wrk -t4 -c100 -d30s --latency -H "Connection: close" http://localhost:8080
# --latency prints detailed percentile distribution
wrk — custom timeoutSet request timeout.
wrk -t2 -c50 -d10s --timeout 5s http://localhost:8080/api

wrk Scripting

wrk — POST via LuaPOST request with body.
-- post.lua
wrk.method = "POST"
wrk.body = '{"name": "test"}'
wrk.headers["Content-Type"] = "application/json"

wrk -t4 -c100 -d30s -s post.lua http://localhost:8080/users
wrk — auth tokenDynamic header per request.
-- auth.lua
token = os.getenv("TOKEN")
request = function()
  wrk.headers["Authorization"] = "Bearer " .. token
  return wrk.format("GET", "/api/users")
end

TOKEN=abc123 wrk -t2 -c10 -d10s -s auth.lua http://localhost:8080

hey Basics

hey — basicSimple GET benchmark.
hey -n 10000 -c 100 https://api.example.com/users
# -n: total requests, -c: concurrent workers
hey -z 30s -c 50 https://api.example.com/users
hey — POST JSONBenchmark POST endpoint.
hey -n 5000 -c 50 -m POST \
  -H "Content-Type: application/json" \
  -d '{"email":"test@test.com","password":"123456"}' \
  https://api.example.com/login
hey — custom headersMultiple headers.
hey -n 1000 -c 10 \
  -H "Authorization: Bearer token123" \
  -H "X-Request-Id: ${RANDOM}" \
  https://api.example.com/protected
hey — HTTP/2Force HTTP/2.
hey -n 10000 -c 100 -h2 https://example.com/grpc-endpoint

Analysis

Parse resultsExtract key metrics.
# Extract p99 latency from wrk output
wrk -t2 -c50 -d10s --latency http://localhost:8080 | grep "99%"

# hey JSON output for programmatic use
hey -n 1000 -c 50 -o json https://example.com | jq '.latencyPercentiles