These benchmarks are based on the fastify benchmarks repo! in fact our goal is to perform similar to fastify as we considered it the industry standard in terms of performance.
mion is focused on being lightweight and fast so it can be run in serverless environments. We run the benchmarks before every PR gets merged to ensure there is no performance regression.
This is a simple hello world scenario, is a good indicator of the router performance and theoretical upper limit of each framework.
import {HeadersSubset, RpcError} from '@mionkit/core';
import {RouterOptions, initMionRouter, headersFn, middleFn, route} from '@mionkit/router';
export type User = {id: string; name: string; surname: string};
// set options and init router
export const routerOptions: Partial<RouterOptions> = {prefix: 'api/v1'};
export const myApi = await initMionRouter(
// all function parameters will be automatically validated before the function is called
{
auth: headersFn((ctx, h: HeadersSubset<'Authorization'>): void | RpcError<'not-authorized'> => {
const token = h.headers.Authorization;
if (!token) return new RpcError<'not-authorized'>({publicMessage: 'Not Authorized', type: 'not-authorized'});
}),
users: {
sayHello: route((ctx, user: User): string => `Hello ${user.name} ${user.surname}`),
},
log: middleFn((ctx): void => console.log(Date.now(), ctx.path, ctx.response.statusCode), {runOnError: true}),
},
routerOptions
);
// Export the type of the Api (used by the client)
export type MyApi = typeof myApi;
v24.13.0autocannon -c 100 -d 20.01 -p 10 localhost:3000 (two rounds; one to warm-up, one to measure)| Version | Router | Req (R/s) | Latency (ms) | Output (Mb/s) | Max Memory (Mb) | Max Cpu (%) | Validation | Description | |
|---|---|---|---|---|---|---|---|---|---|
| http-node | 16.18.0 | ✗ | 127536.0 | 7.43 | 22.74 | 146 | 108 | ✓ | bare node http server with Zod validation |
| mion | 0.6.2 | ✓ | 112435.2 | 8.31 | 21.98 | 224 | 108 | ✓ | Automatic validation and serialization out of the box |
| hono | 3.12.6 | ✓ | 104310.4 | 9.07 | 17.11 | 231 | 108 | ✓ | hono node server with Zod validation |
| hapi | 21.4.4 | ✓ | 89321.6 | 10.74 | 15.93 | 253 | 111 | ✓ | Hapi with Zod validation |
| fastify | 5.7.4 | ✓ | 86547.2 | 10.99 | 15.52 | 156 | 108 | ✓ | Fastify with native JSON Schema validation |
| express | 5.2.1 | ✓ | 75843.2 | 12.70 | 13.52 | 236 | 109 | ✓ | Express with Zod validation |