How fast
Benchmarks against node:http, Fastify, Hono and Express.
Not to win, but to know. Twelve scenarios, from a fixed answer to a body of 50 objects checked one by one, a router of 400 routes, 404s and 400s. Every server does the same work: inkan and Fastify check with schemas, the others by hand, and every answer is checked before it is measured. All servers run at once and each scenario is measured for all of them back to back, so a runner that slows down slows everybody alike. One GitHub runner with 4 cores, 15 seconds per scenario after a warm-up, 3 rounds each; the median of three such runs:
| score | hello, 100 connections | params + query | body of 50 | answer of 100 | 400 routes | 404 | 400 | |
|---|---|---|---|---|---|---|---|---|
| inkan on uWebSockets.js ¹ | 134.4 | 147 % | 148 % | 104 % | 99 % | 149 % | 154 % | 115 % |
| node:http, by hand | 100 | 100 % | 100 % | 100 % | 100 % | 100 % | 100 % | 100 % |
| inkan, sealed | 93.2 | 96 % | 95 % | 99 % | 90 % | 92 % | 97 % | 76 % |
| inkan | 91.0 | 96 % | 91 % | 89 % | 88 % | 89 % | 93 % | 72 % |
| Fastify | 89.9 | 95 % | 97 % | 92 % | 78 % | 91 % | 94 % | 63 % |
| Hono | 84.5 | 92 % | 78 % | 89 % | 97 % | 75 % | 78 % | 82 % |
| Express | 46.0 | 49 % | 47 % | 62 % | 70 % | 21 % | 21 % | 49 % |
¹ With @inkanjs/uws, measured with 0.6.0 in a run of its own, against node:http in that run.
The score is the geometric mean over all twelve scenarios against bare node:http,
so no single one can carry or sink a server. inkan does a little more per request
than the others: it gives every request an id and keeps back every key an answer's
contract does not list. Read the numbers as a range, not a rank: a run on another
day moves each server by a few points. inkan is level with Fastify or a little ahead: in
front in two of three runs, level in the third, and not in every scenario (Fastify leads
params + query and 3 middlewares). As fast as 0.7.0, measured as CPU per request. With
inkan seal, a body of 50 objects is checked faster than by any of them. How 0.8.0 got here
is in bench/reports/0.8.0.md.
Run it yourself: cd bench && npm install && node run.mjs, or the bench workflow
on GitHub, which also measures what one request costs the server in CPU time.