Measure and compare API endpoint performance
REST API Benchmarking
Get precise latency percentiles (p50, p95, p99) for every REST endpoint. Compare performance across deployments, identify slow queries, and establish SLA baselines.
Percentile-based latency metrics (p50, p95, p99)
Endpoint-by-endpoint comparison
Throughput measurement (requests/second)
Error rate tracking
Custom thresholds and SLA validation
Historical comparison across test runs
benchmark.js
import http from 'k6/http';
import { check } from 'k6';
import { Trend } from 'k6/metrics';
const getUsers = new Trend('get_users_duration');
const getOrders = new Trend('get_orders_duration');
export const options = {
vus: 100,
duration: '5m',
thresholds: {
get_users_duration: ['p(95)<300'],
get_orders_duration: ['p(95)<500'],
},
};
export default function () {
const users = http.get('https://api.example.com/users');
getUsers.add(users.timings.duration);
const orders = http.get('https://api.example.com/orders');
getOrders.add(orders.timings.duration);
}Frequently asked questions
Related guides
Run this as a plan
Put the scenario in your app's Config/load-plan.json and run it from the narduk-app CLI.