Benchmark environment:
- Fastify (https://github.com/fastify/fastify),
next
branch (commit 3486afe04a05c0874c63010f7525361a316905fe) - Node.js v12.13.1
- Autocannon (https://github.com/mcollina/autocannon) v4.6.0
Web app:
node --jitless ./examples/simple.js
Benchmark result:
$ npx autocannon -c 100 -d 30 -p 10 localhost:3000
Running 30s test @ http://localhost:3000
100 connections with 10 pipelining factor
┌─────────┬──────┬──────┬────────┬────────┬──────────┬──────────┬───────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────┼──────┼────────┼────────┼──────────┼──────────┼───────────┤
│ Latency │ 0 ms │ 0 ms │ 158 ms │ 167 ms │ 15.38 ms │ 46.25 ms │ 225.72 ms │
└─────────┴──────┴──────┴────────┴────────┴──────────┴──────────┴───────────┘
┌───────────┬────────┬────────┬─────────┬─────────┬─────────┬─────────┬────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼────────┼────────┼─────────┼─────────┼─────────┼─────────┼────────┤
│ Req/Sec │ 5919 │ 5919 │ 6487 │ 6675 │ 6412.14 │ 226.97 │ 5918 │
├───────────┼────────┼────────┼─────────┼─────────┼─────────┼─────────┼────────┤
│ Bytes/Sec │ 971 kB │ 971 kB │ 1.06 MB │ 1.09 MB │ 1.05 MB │ 37.2 kB │ 971 kB │
└───────────┴────────┴────────┴─────────┴─────────┴─────────┴─────────┴────────┘
Req/Bytes counts sampled once per second.
192k requests in 30.04s, 31.5 MB read
Web app:
node ./examples/simple.js
Benchmark result:
$ npx autocannon -c 100 -d 30 -p 10 localhost:3000
Running 30s test @ http://localhost:3000
100 connections with 10 pipelining factor
┌─────────┬──────┬──────┬───────┬───────┬─────────┬──────────┬───────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────┼──────┼───────┼───────┼─────────┼──────────┼───────────┤
│ Latency │ 0 ms │ 0 ms │ 54 ms │ 70 ms │ 5.45 ms │ 16.56 ms │ 160.85 ms │
└─────────┴──────┴──────┴───────┴───────┴─────────┴──────────┴───────────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬──────────┬─────────┬─────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼─────────┼─────────┤
│ Req/Sec │ 12103 │ 12103 │ 18223 │ 19727 │ 18080.94 │ 1264.78 │ 12101 │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼─────────┼─────────┤
│ Bytes/Sec │ 1.99 MB │ 1.99 MB │ 2.99 MB │ 3.23 MB │ 2.97 MB │ 207 kB │ 1.98 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴──────────┴─────────┴─────────┘
Req/Bytes counts sampled once per second.
542k requests in 30.05s, 89 MB read
As expected, even for a simple, syntetic web app the difference is noticeable.