Benchmarks¶
Typeix benchmark results against Express, Fastify and NestJS on Node 26, plus the exact source code each framework ran.
I am not a fan of micro benchmarks, because real applications can be optimised on many layers. Every implementation below answers the same single route — GET / returning {"hello":"world"} — so the numbers describe routing and serialization overhead, not the cost of your database, your templates or your business logic. Use them as an upper bound on framework overhead and as a starting point, then measure your own workload.
Both the code and the numbers on this page are generated from the benchmarks repository, so what you read is what ran.
Results — 2026, Node 26¶
All implementations are clustered across the available CPUs, so throughput is per container, not per core.
- Machine: Apple M4 Max, 16 cores, 128 GB
- Container:
node:26, 4 vCPU, 4 GB RAM, linux/x64 - Method:
autocannon -c 100 -d 40 -p 10 localhost:3000— two rounds per implementation, one to warm up and one to measure. The second round is what is reported.
| Version | Router | Requests/s | Latency | Throughput/MB | |
|---|---|---|---|---|---|
@typeix/resty | ^9.1.0 | ✓ | 363974 | 2.12 | 50.96 |
@typeix/router | ^9.1.0 | ✓ | 338867 | 2.3 | 47.44 |
express | ^5.3.0 | ✓ | 331290 | 2.41 | 61.95 |
@nestjs/platform-fastify | ^12.6.3 | ✓ | 330419 | 2.42 | 62.12 |
fastify | ^5.12.8 | ✓ | 314003 | 2.74 | 59.03 |
@nestjs/platform-express | ^12.6.3 | ✓ | 295770 | 3.01 | 74.53 |
Source, harness and raw results: typeix/benchmarks. Each row comes from the matching file in results/; the first column is the module the harness forked.
What is measured¶
The workload is deliberately trivial: one route, one small JSON object, no middleware, no templating, no I/O. That isolates the framework's own cost — route matching, dependency resolution, serialization — and keeps the comparison like-for-like across six very different designs.
Every implementation is wrapped in the same cluster helper, so all six use every CPU in the container:
import {availableParallelism} from "node:os";
import cluster from "node:cluster";
const numCPUs = availableParallelism();
export function clusterNode(callback: () => void, enabled: boolean = true): void {
if (cluster.isPrimary && enabled) {
console.log(`Primary ${process.pid} is running`);
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', (worker, code, signal) => {
console.log(`worker ${worker.process.pid} died`);
});
} else {
callback();
console.log(`Worker ${process.pid} started`);
}
}
The harness forks the implementation, waits for the port to accept connections, then fires autocannon three times: an unrecorded warm-up, and a recorded round whose JSON is written to results/:
#!/usr/bin/env node
'use strict'
const { fork } = require('child_process')
// ora is ESM-only, require() exposes its default export on .default
const ora = require('ora').default
const path = require('path')
const { fire } = require('./autocannon')
const doBench = async (opts, handler) => {
const spinner = ora(`Started ${handler}`).start()
const forked = fork(path.join(__dirname, '..', 'benchmarks', handler))
try {
spinner.color = 'magenta'
spinner.text = `Warming ${handler}`
await fire(opts, handler, false)
} catch (error) {
return console.log(error)
} finally {
spinner.color = 'yellow'
spinner.text = `Working ${handler}`
}
try {
await fire(opts, handler, true)
forked.kill('SIGINT')
spinner.text = `Results saved for ${handler}`
spinner.succeed()
return true
} catch (error) {
return console.log(error)
}
}
let index = 0
const start = async (opts, list) => {
if (list.length === index) {
return true
}
try {
await doBench(opts, list[index])
index += 1
return start(opts, list)
} catch (error) {
return console.log(error)
}
}
module.exports = start
The full run is six implementations × 2 rounds × 40 s, in a container pinned to the benchmark hardware:
FROM node:26
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN rm -fR node_modules
RUN ls -la
RUN npm install
RUN ls -la
CMD ["node", "benchmark-bench-selected.js"]
docker build . -t typeix/benchmarks
docker run --cpus=4 --volume=$(pwd)/results:/usr/src/app/results typeix/benchmarks
The code that was measured¶
These are the exact sources from the repository, shown as TypeScript where the harness compiles from TypeScript and as JavaScript where the file is written directly. Every one of them produces the same response body.
import {pipeServer, Controller, GET, RootModule, Logger, Router} from "@typeix/resty";
import {createServer} from "http";
import {clusterNode} from "./cluster";
// resty supports http, https, http2
// define controller
@Controller({
path: "/"
})
class HomeController {
@GET()
actionGet() {
return {hello: "world"};
}
}
// DEFINE MODULE
@RootModule({
imports: [], // here you can import other modules
shared_providers: [
{
provide: Logger,
useFactory: () => new Logger({
options: {
level: "info"
}
})
},
Router
],
providers: [],
controllers: [HomeController]
})
class ApplicationModule {
}
// START SERVER
async function bootstrap() {
const server = createServer();
await pipeServer(server, ApplicationModule);
server.listen(3000);
}
clusterNode(bootstrap);
import {createServer} from "http";
import {Injector, IResolvedRoute, Router} from "@typeix/router";
import {clusterNode} from "./cluster";
export function bootstrap() {
let router: Router = Injector.Sync.createAndResolve(Router, []).get(Router);
router.get("/", (injector: Injector, route: IResolvedRoute) => {
return {hello: "world"};
});
let server = router.pipe(createServer());
server.listen(3000);
}
clusterNode(bootstrap);
'use strict'
const cluster = require("./cluster");
const express = require('express')
cluster.clusterNode(() => {
const app = express()
app.disable('etag')
app.disable('x-powered-by')
app.get('/', function (req, res) {
res.json({ hello: 'world' })
})
app.listen(3000);
});
'use strict'
const cluster = require("./cluster");
cluster.clusterNode(() => {
const fastify = require('fastify')()
const schema = {
schema: {
response: {
200: {
type: 'object',
properties: {
hello: {
type: 'string'
}
}
}
}
}
};
fastify.get('/', schema, function (req, reply) {
reply.send({ hello: 'world' })
});
fastify.listen({
port: 3000
});
});
import {Controller, Get, Module} from "@nestjs/common";
import {NestFactory} from "@nestjs/core";
import {FastifyAdapter, NestFastifyApplication} from "@nestjs/platform-fastify";
import {clusterNode} from "./cluster";
@Controller("/")
class HelloWorldController {
@Get()
helloWorld(): any {
return {hello: "world"};
}
}
@Module({
controllers: [HelloWorldController]
})
export class AppModule {
}
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter(),
);
await app.listen(3000);
}
clusterNode(bootstrap);
import {Controller, Get, Module} from "@nestjs/common";
import {NestFactory} from "@nestjs/core";
import {clusterNode} from "./cluster";
@Controller("/")
class HelloWorldController {
@Get()
helloWorld(): any {
return {hello: "world"};
}
}
@Module({
controllers: [HelloWorldController]
})
export class AppModule {
}
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
clusterNode(bootstrap);
Reading the numbers honestly¶
- Express and NestJS report higher throughput/MB with fewer requests. Their responses carry more headers, so the same request count moves more bytes. Bytes per second is not a quality signal; requests per second and latency are.
- The spread is small. Roughly 364k vs 296k requests/s between the fastest and slowest implementation here — about 20%. At this level, framework choice is rarely what limits an application; your database calls and payload sizes are.
- Clustering flattens differences. With four workers, per-request CPU cost is divided by four, so absolute numbers are container-shaped. Compare ratios, not absolute request counts.
@typeix/routerand@typeix/restyare not rivals. Resty is the full framework built on the same router, and it measures slightly faster here because it serializes responses in its own request handler.- Node version matters more than the framework. These are Node 26 LTS figures; the 2021 numbers below are ten to twenty times lower on Node 14 with a different machine.
Reproduce them on your own hardware before drawing conclusions about your deployment.
Historical results¶
2021 — node:14, Typeix 7.x
The original comparison, kept for reference. Frameworks here were single-process; later runs are clustered.
- Machine: Ryzen 7 3800X, 8c/16t | docker linux x64 | 2 vCPU | 4GB RAM
- Node:
node:14 - Method:
autocannon -c 100 -d 40 -p 10 localhost:3000(two rounds; one to warm-up, one to measure)
| Version | Router | Requests/s | Latency | Throughput/Mb | |
|---|---|---|---|---|---|
fastify | ^3.0.0 | ✓ | 81185.61 | 11.82 | 15.18 |
@nestjs/platform-fastify | ^7.6.15 | ✓ | 68189.2 | 14.17 | 12.75 |
@typeix/router | ^7.4.1 | ✓ | 65384.4 | 14.8 | 9.15 |
@typeix/resty | ^7.4.1 | ✓ | 55476.8 | 17.53 | 7.77 |
express | ^4.16.4 | ✓ | 17665.6 | 56.1 | 3.30 |
@nestjs/platform-express | ^7.6.15 | ✓ | 14079 | 70.47 | 3.55 |