Skip to content

Benchmarking Guide

Terminal window
# Install benchmarking tools
cargo install oha
# Build the benchmark harness
cargo build --release -p justapi-bench
Terminal window
# Build a baseline workload
python benchmarks/workloads_justapi.py &
oha -z 30s -c 100 http://localhost:8000/hello
oha -z 30s -c 100 http://localhost:8000/echo
Terminal window
# JustAPI vs FastAPI vs Robyn with SQLite
bash benchmarks/run_crud_bench.sh
Terminal window
cargo run --release -p justapi-bench --bin justapi-bench
  1. Warm up: Minimum 5 seconds before recording
  2. Run: 30 seconds, 100 concurrent connections
  3. Repeat: Minimum 3 runs per workload
  4. Record: p50, p95, p99 latency, RPS, peak RSS
Name Route Method Description
hello-world /hello GET Static JSON response
json-echo /echo POST Nested JSON payload echoed
db-sim /db GET Simulated DB query (5ms sleep)
native /native POST Native fast path (724k+ RPS)
crud-read /items GET SQLite SELECT
crud-write /items POST SQLite INSERT

A p99 regression >5% compared to the previous baseline fails the benchmark gate. The CI workflow (bench.yml) enforces this:

PR_RPS >= 0.95 * MAIN_RPS # Must pass
Requests/sec: 701,234
Latency:
p50: 0.07 ms
p95: 0.12 ms
p99: 0.19 ms
  • RPS: Higher is better
  • p50: Typical latency (median)
  • p99: Worst-case latency (tail)
  • Difference between p50 and p99: Indicates latency consistency

Record the exact hardware when benchmarking:

CPU: 13th Gen Intel Core i5-13600K
RAM: 31 GiB DDR5
OS: CachyOS Linux
Kernel: 6.x

Comparisons are only valid on the same hardware.

  1. Add your workload to benchmarks/workloads_*.py
  2. Add a new workload entry in BENCHMARKS.md
  3. Run 3+ iterations and record all numbers
  4. Do not overwrite historical data — append