Skip to Content
Overhead Performance

Overhead Performance

TL;DR

  • Goal: measure Vovk.ts overhead over native Next.js route handlers (not HTTP stack).
  • Routing: O(1) across 1–10,000 controllers (20,000 endpoints). Median latency ~1.1 µs; at 10,000 controllers ~1.3 µs. Throughput ~750k–930k ops/s/core.
  • Cold start: O(n). ~5.5 ms at 1,000 controllers; ~63 ms at 10,000. About 8–10× the cost of no‑op decorators.
  • Notes: Tinybench on Apple M4 Pro. Next.js runtime cost is out of scope. Compiled from real benchmark output with AI assistance and minor edits. See vovk-perf-test repo for scripts.

Reproducing the Tests

Clone the repo:

git clone https://github.com/finom/vovk-perf-test.git cd vovk-perf-test

Install dependencies via:

npm i

Run performance tests via:

npm run perf-test

Overview

Vovk.ts sits on top of Next.js API routes and generates handlers via decorators applied to controller methods:

src/app/api/[[...vovk]]/route.ts
export const { GET, POST } = initSegment({ controllers });

We measure framework overhead in two dimensions:

  • Request Overhead: per-request routing/handler overhead.
  • Cold Start Overhead: initialization time for controllers/metadata.

Source: test scripts in the vovk-perf-test repository.

Request Overhead

Methodology (short)

  • Autogenerate N controllers (N ∈ {1, 10, 100, 1,000, 10,000}), each exposing:
    • GET without params (reject unexpected id).
    • POST with path param “{id}” (require id).
  • Minimal handler logic; measure full routing + handler path.
  • Tinybench: 100 ms min per test, nanosecond timing; report median latency/throughput.

Results

ControllersEndpointsGET Latency (med)POST Latency (med)GET Throughput (med ops/s)POST Throughput (med ops/s)
121,083 ns1,042 ns923,361959,693
10201,084 ns1,083 ns922,509923,361
1002001,083 ns1,125 ns923,361888,889
1,0002,0001,083 ns1,125 ns923,361888,889
10,00020,0001,292 ns1,333 ns773,994750,188

Key takeaways:

  • O(1) routing: stable latency from 1 to 1,000 controllers; small bump at 10,000.
  • Sub‑µs overhead at typical scales; GET≈POST indicates efficient param extraction.

Cold Start Overhead

Methodology (short)

For N ∈ {1, 10, 100, 1,000, 10,000} measure:

  • App creation, decorator processing, metadata build, and initSegment().
  • Compare to equivalent classes using no‑op decorators to isolate framework work.

Example no‑op decorators:

function noopDecorator() { return function (..._args: any[]) {}; } function noopClassDecorator() { return function <T extends new (...a: any[]) => any>(c: T) { return c; }; }

Results

ControllersVovk.ts Init Time (med)No-op Time (med)Overhead RatioThroughput (ops/s)
15.7 μs0.54 μs10.6x175,193
1052.7 μs5.1 μs10.3x18,972
100520.1 μs52.4 μs9.9x1,923
1,0005,519.8 μs646.1 μs8.5x181
10,00062,769.2 μs7,629.1 μs8.2x16

Key takeaways:

  • O(n) init: linear in controller count with stable per‑controller cost.
  • Absolute times are small for long‑lived services; still acceptable for serverless at typical sizes.

Practical guidance

  • For high-performance workloads: split the app into multiple segments (e.g., serverless functions built with Next.js route.ts files).
  • In theory, with careful segment management and adequate hardware, a single Next.js/Vovk.ts app can host up to ~1,000,000 endpoints. Validate this in your environment; practical limits will be memory, bundle size, cold start budgets, and platform quotas.

Benchmarks: Tinybench on Node.js; hardware Apple M4 Pro. Numbers can vary by runtime, hardware, and build settings. Scripts/results: https://github.com/finom/vovk-perf-test 

Last updated on