All apps employ two global middlewares with req
mutations, an empty GET
route handler for favicon.ico
and a GET handler for the /users/:id
, returning a User: {id}
string response.
Results are taken after one run. The command used for results is the following:
node run.mjs
run.mjs
is a script that launches a child process with the app and runs benchmarks against it, recursively, going to the next app in the list.
Xiaomi Laptop with 16GB RAM and Intel Core i7-8550U processor.
- OS: Manjaro Linux
- Kernel version: 5.7.19-2-MANJARO
- Node.js: 14.9.0
Note: benchmarks aren't completely accurate and are different on every run and on every machine. You need to compare proportions instead of absolute values.
The table takes average results.
framework | req/s | transfer/sec | latency |
---|---|---|---|
@tinyhttp/app (esm) | 21532 | 2.82 MB | 4.11 ms |
@tinyhttp/app (cjs) | 19937 | 1.87 MB | 4.44 ms |
express@4.17.1 | 9410 | 1.45 MB | 10.05 ms |
polka@0.5.2 | 28233 | 3.7 MB | 3.12 ms |
koa@2.13 + @koa/router@9.4 | 19654 | 3.38 MB | 4.51 ms |
Conclusion: tinyhttp is ~2.3x faster than Express and ~1.3x slower than Polka.
- tinyhttp (esm)
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼────────┤
│ Latency │ 3 ms │ 4 ms │ 7 ms │ 8 ms │ 4.11 ms │ 2.16 ms │ 117 ms │
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴────────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬──────────┬─────────┬─────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼─────────┼─────────┤
│ Req/Sec │ 15455 │ 15455 │ 21679 │ 26287 │ 21532.54 │ 2568.13 │ 15448 │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼─────────┼─────────┤
│ Bytes/Sec │ 2.02 MB │ 2.02 MB │ 2.84 MB │ 3.44 MB │ 2.82 MB │ 336 kB │ 2.02 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴──────────┴─────────┴─────────┘
Req/Bytes counts sampled once per second.
323k requests in 15.05s, 42.3 MB read
- tinyhttp (cjs)
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬───────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼───────┤
│ Latency │ 3 ms │ 4 ms │ 7 ms │ 8 ms │ 4.44 ms │ 1.64 ms │ 68 ms │
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴───────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬──────────┬─────────┬─────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼─────────┼─────────┤
│ Req/Sec │ 13799 │ 13799 │ 20031 │ 24719 │ 19937.34 │ 2117.98 │ 13799 │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼─────────┼─────────┤
│ Bytes/Sec │ 1.81 MB │ 1.81 MB │ 2.63 MB │ 3.24 MB │ 2.61 MB │ 277 kB │ 1.81 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴──────────┴─────────┴─────────┘
Req/Bytes counts sampled once per second.
299k requests in 15.03s, 39.2 MB read
400 errors (0 timeouts)
- express@4.17.1
┌─────────┬──────┬──────┬───────┬───────┬──────────┬─────────┬───────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────┼──────┼───────┼───────┼──────────┼─────────┼───────┤
│ Latency │ 8 ms │ 9 ms │ 16 ms │ 22 ms │ 10.05 ms │ 2.59 ms │ 62 ms │
└─────────┴──────┴──────┴───────┴───────┴──────────┴─────────┴───────┘
┌───────────┬────────┬────────┬─────────┬─────────┬─────────┬─────────┬────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼────────┼────────┼─────────┼─────────┼─────────┼─────────┼────────┤
│ Req/Sec │ 4299 │ 4299 │ 9895 │ 10223 │ 9410.27 │ 1419.86 │ 4297 │
├───────────┼────────┼────────┼─────────┼─────────┼─────────┼─────────┼────────┤
│ Bytes/Sec │ 662 kB │ 662 kB │ 1.52 MB │ 1.57 MB │ 1.45 MB │ 219 kB │ 662 kB │
└───────────┴────────┴────────┴─────────┴─────────┴─────────┴─────────┴────────┘
Req/Bytes counts sampled once per second.
141k requests in 15.04s, 21.7 MB read
700 errors (0 timeouts)
- polka@0.5.2
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬───────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼───────┤
│ Latency │ 2 ms │ 3 ms │ 4 ms │ 5 ms │ 3.12 ms │ 0.99 ms │ 47 ms │
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴───────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬──────────┬────────┬─────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼────────┼─────────┤
│ Req/Sec │ 18591 │ 18591 │ 28863 │ 29695 │ 28233.07 │ 2634.5 │ 18584 │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼────────┼─────────┤
│ Bytes/Sec │ 2.44 MB │ 2.44 MB │ 3.78 MB │ 3.89 MB │ 3.7 MB │ 345 kB │ 2.43 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴──────────┴────────┴─────────┘
Req/Bytes counts sampled once per second.
423k requests in 15.03s, 55.5 MB read
200 errors (0 timeouts)
- koa@2.13 + @koa/router@9.4
┌─────────┬──────┬──────┬───────┬───────┬─────────┬─────────┬────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────┼──────┼───────┼───────┼─────────┼─────────┼────────┤
│ Latency │ 3 ms │ 4 ms │ 7 ms │ 11 ms │ 4.51 ms │ 2.56 ms │ 123 ms │
└─────────┴──────┴──────┴───────┴───────┴─────────┴─────────┴────────┘
┌───────────┬─────────┬─────────┬─────────┬────────┬──────────┬─────────┬─────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────────┼─────────┼─────────┼────────┼──────────┼─────────┼─────────┤
│ Req/Sec │ 7263 │ 7263 │ 20639 │ 21487 │ 19654.27 │ 3375.06 │ 7262 │
├───────────┼─────────┼─────────┼─────────┼────────┼──────────┼─────────┼─────────┤
│ Bytes/Sec │ 1.25 MB │ 1.25 MB │ 3.55 MB │ 3.7 MB │ 3.38 MB │ 581 kB │ 1.25 MB │
└───────────┴─────────┴─────────┴─────────┴────────┴──────────┴─────────┴─────────┘
Req/Bytes counts sampled once per second.
295k requests in 15.02s, 50.7 MB read
700 errors (0 timeouts)