Load generators
Separate subpath exports for load scenarios.
runHttp1Load()runWebSocketLoad()@swarmmachina/benchkit/load/http1@swarmmachina/benchkit/load/websocket@swarmmachina/benchkit v0.3.1
Benchmark / load generation
Zero-runtime-dependency tools for reproducible Node.js benchmarks: HTTP/1.1 and WebSocket load generators, latency histograms, CPU, ELU, memory, and regression guards.
Use it to measure services and guard against regressions. Load generators run in worker threads; run the target service separately so target measurements do not mix with generator process metrics.
npm install --save-dev @swarmmachina/benchkitimport { runHttp1Load } from '@swarmmachina/benchkit/load/http1'
const result = await runHttp1Load({
name: 'health',
url: 'http://127.0.0.1:3000/health',
connections: 100,
pipelining: 10,
workers: 4,
warmupMs: 2_000,
durationMs: 10_000
})
console.log({
rps: result.requests.averagePerSecond,
p95Ms: result.latencyMs.p95Ms,
p99Ms: result.latencyMs.p99Ms,
errors: result.errors.total,
dropped: result.transport.rateDropped
})| Environment | Status | Note |
|---|---|---|
| Node.js ^22.13.0 / 24.x | Supported | Native ESM and worker threads; Node.js 26 is outside the engine range. |
| HTTP / HTTPS | HTTP/1.1 | Close-delimited responses and HTTP upgrades are rejected. |
| WebSocket target | Echo / request-response | Every response completes the oldest in-flight message; unsolicited messages are protocol errors. |
| SSH orchestration | Optional | Requires ssh, tar, key-based authentication, and direct access to the load port. |
Separate subpath exports for load scenarios.
runHttp1Load()runWebSocketLoad()@swarmmachina/benchkit/load/http1@swarmmachina/benchkit/load/websocketMeasurements, statistics, and result artifacts.
./measurement./statistics./profiling./reporting./resultsGuards and local/remote target lifecycle.
./regression./baseline./control./target./target-provider./orchestrationComplete signatures, types, and examples are available in the source repository README and TypeScript declarations.
Results depend on the service, the generator, and the runtime environment. Retain all three parts of that context.
Generator CPU and RSS include unrelated work in the caller process. Use a separate process or host for the target.
When connections × pipelining or connections × maxInFlight is exhausted, new arrivals are dropped and counted in rateDropped.
The HTTP generator supports Content-Length, chunked, interim 1xx, HEAD, 204, and 304. WebSocket targets must behave as echo/request-response endpoints.
Read loadGenerator CPU, worker ELU, and memory together with errors and scheduling lag. High RPS alone does not establish service headroom.
Use the separate WebSocket generator for an echo endpoint. maxInFlight bounds outstanding messages per connection.
import { runWebSocketLoad } from '@swarmmachina/benchkit/load/websocket'
const result = await runWebSocketLoad({
url: 'ws://127.0.0.1:3000/echo',
message: '{"type":"ping"}',
connections: 100,
maxInFlight: 4,
workers: 4,
warmupMs: 2_000,
durationMs: 10_000
})
console.log(result.messages.averagePerSecond, result.latencyMs.p99Ms)