Benchmarking Guide
# Install benchmarking toolscargo install oha
# Build the benchmark harnesscargo build --release -p justapi-benchRunning Benchmarks
Section titled “Running Benchmarks”Standard Workloads
Section titled “Standard Workloads”# Build a baseline workloadpython benchmarks/workloads_justapi.py &oha -z 30s -c 100 http://localhost:8000/hellooha -z 30s -c 100 http://localhost:8000/echoCRUD Benchmarks (DB-backed)
Section titled “CRUD Benchmarks (DB-backed)”# JustAPI vs FastAPI vs Robyn with SQLitebash benchmarks/run_crud_bench.shSerialization Benchmarks
Section titled “Serialization Benchmarks”cargo run --release -p justapi-bench --bin justapi-benchBenchmark Protocol
Section titled “Benchmark Protocol”- Warm up: Minimum 5 seconds before recording
- Run: 30 seconds, 100 concurrent connections
- Repeat: Minimum 3 runs per workload
- Record: p50, p95, p99 latency, RPS, peak RSS
Key Workloads
Section titled “Key Workloads”| 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 |
Regression Gate
Section titled “Regression Gate”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 passInterpreting Results
Section titled “Interpreting Results”Requests/sec: 701,234Latency: 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
Hardware Fixture
Section titled “Hardware Fixture”Record the exact hardware when benchmarking:
CPU: 13th Gen Intel Core i5-13600KRAM: 31 GiB DDR5OS: CachyOS LinuxKernel: 6.xComparisons are only valid on the same hardware.
Adding New Benchmarks
Section titled “Adding New Benchmarks”- Add your workload to
benchmarks/workloads_*.py - Add a new workload entry in
BENCHMARKS.md - Run 3+ iterations and record all numbers
- Do not overwrite historical data — append
See Also
Section titled “See Also”- Performance Tuning — Optimize your app
- BENCHMARKS.md
- Benchmark Harness Skill