Hello World Benchmarks
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.
Please always take benchmarks as general guidelines as you might obtain different results in your real world application. we just run the benchmarks to ensure there is no performance degradation when new features/fixes are added to mion.
What is tested?
This is a simple hello world scenario, is a good indicator of the router performance and theoretical upper limit of each framework.
// ### mion ###
export const routes = {
sayHello: (): string => ({hello: "world"}),
} satisfies Routes;
// ### Express ###
app.get("/sayHello", function (req, res) {
res.json({ hello: "world" });
});
Notes
mion creates standard Request, Response & Headers Object for each incoming request. This is so mion can be used in multiple platforms. Even if we sacrifice a bit of performance in exchange for flexibility, mion is still pretty performant.
Benchmarks
- Machine: darwin x64 | 8 vCPUs | 16.0GB Mem
- Node:
v20.11.0
- Run: Mon Jan 29 2024 22:27:22 GMT+0000 (Greenwich Mean Time)
- Method:
autocannon -c 100 -d 40.02 -p 10 localhost:3000
(two rounds; one to warm-up, one to measure)
Req (R/s)
Throughput (Mb/s)
Latency (ms)
Max Memory (Mb)
Memory Series (MB)
Results Table
Version | Router | Req (R/s) | Latency (ms) | Output (Mb/s) | Max Memory (Mb) | Max Cpu (%) | Validation | Description | |
---|---|---|---|---|---|---|---|---|---|
mion.bun | 0.6.2 | โ | 63724.8 | 15.19 | 9.91 | 87 | 107 | โ | mion using bun, automatic validation and serialization |
http-node | 16.18.0 | โ | 39481.6 | 24.83 | 7.04 | 81 | 129 | โ | bare node http server, should be the theoretical upper limit in node.js performance |
fastify | 4.10.2 | โ | 39065.6 | 25.10 | 7.00 | 87 | 123 | - | Validation using schemas and ajv. schemas are generated manually |
mion | 0.6.2 | โ | 33488.6 | 29.35 | 6.71 | 91 | 127 | โ | Automatic validation and serialization out of the box |
hono | 3.12.6 | โ | 29306.0 | 33.61 | 5.23 | 89 | 123 | โ | hono node server, manual validation or third party tools |
hapi | 21.3.2 | โ | 26155.6 | 37.72 | 4.66 | 101 | 128 | โ | validation using joi or third party tools |
restify | 11.1.0 | โ | 10475.8 | 94.94 | 2.59 | 165 | 144 | โ | manual validation or third party tools |
express | 4.18.2 | โ | 8172.9 | 121.70 | 1.46 | 121 | 126 | โ | manual validation or third party tools |