Skip to content

Instantly share code, notes, and snippets.

@BobbyWibowo
Last active July 20, 2022 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BobbyWibowo/e2d1a6d46443323e139f15094c3984d8 to your computer and use it in GitHub Desktop.
Save BobbyWibowo/e2d1a6d46443323e139f15094c3984d8 to your computer and use it in GitHub Desktop.
# Hyper-Express
$ autocannon http://localhost:3001/api/check --renderStatusCodes --debug --warmup [ -c 2500 -d 30 ] -c 2500 -d 30 -p 4
┌─────────┬────────┬────────┬────────┬────────┬───────────┬──────────┬────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼────────┼────────┼────────┼────────┼───────────┼──────────┼────────┤
│ Latency │ 267 ms │ 447 ms │ 622 ms │ 645 ms │ 427.02 ms │ 76.18 ms │ 708 ms │
└─────────┴────────┴────────┴────────┴────────┴───────────┴──────────┴────────┘
┌───────────┬─────────┬─────────┬─────────┬────────┬──────────┬──────────┬─────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────────┼─────────┼─────────┼────────┼──────────┼──────────┼─────────┤
│ Req/Sec │ 21023 │ 21023 │ 24207 │ 202879 │ 48620.71 │ 49885.69 │ 21016 │
├───────────┼─────────┼─────────┼─────────┼────────┼──────────┼──────────┼─────────┤
│ Bytes/Sec │ 14.3 MB │ 14.3 MB │ 16.4 MB │ 138 MB │ 33 MB │ 33.8 MB │ 14.2 MB │
└───────────┴─────────┴─────────┴─────────┴────────┴──────────┴──────────┴─────────┘
┌──────┬────────┐
│ Code │ Count │
├──────┼────────┤
│ 200 │ 826472 │
└──────┴────────┘
Req/Bytes counts sampled once per second.
# of samples: 17
836k requests in 35.7s, 560 MB read
# ExpressJS
$ autocannon http://localhost:3002/api/check --renderStatusCodes --debug --warmup [ -c 2500 -d 30 ] -c 2500 -d 30 -p 4
┌─────────┬────────┬─────────┬─────────┬──────────┬────────────┬────────────┬──────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼────────┼─────────┼─────────┼──────────┼────────────┼────────────┼──────────┤
│ Latency │ 643 ms │ 2597 ms │ 9645 ms │ 11307 ms │ 3328.36 ms │ 2016.34 ms │ 11482 ms │
└─────────┴────────┴─────────┴─────────┴──────────┴────────────┴────────────┴──────────┘
┌───────────┬─────┬──────┬─────────┬─────────┬─────────┬────────┬────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────┼──────┼─────────┼─────────┼─────────┼────────┼────────┤
│ Req/Sec │ 0 │ 0 │ 3557 │ 4819 │ 3580.14 │ 984.83 │ 1024 │
├───────────┼─────┼──────┼─────────┼─────────┼─────────┼────────┼────────┤
│ Bytes/Sec │ 0 B │ 0 B │ 2.86 MB │ 3.87 MB │ 2.87 MB │ 791 kB │ 822 kB │
└───────────┴─────┴──────┴─────────┴─────────┴─────────┴────────┴────────┘
┌──────┬────────┐
│ Code │ Count │
├──────┼────────┤
│ 200 │ 107378 │
└──────┴────────┘
Req/Bytes counts sampled once per second.
# of samples: 30
121k requests in 30.58s, 86.2 MB read
1k errors (496 timeouts)
$ env FETCH_TOKEN="MY_TOKEN" node ./src/fetch-get.js
/
hyper-express x 1,446 ops/sec ±4.02% (73 runs sampled)
express x 462 ops/sec ±3.36% (69 runs sampled)
Fastest: hyper-express
/api/check
hyper-express x 1,740 ops/sec ±2.32% (75 runs sampled)
express x 927 ops/sec ±1.79% (77 runs sampled)
Fastest: hyper-express
/api/uploads/0
hyper-express x 599 ops/sec ±2.66% (72 runs sampled)
express x 457 ops/sec ±3.32% (73 runs sampled)
Fastest: hyper-express
/api/albums/0
hyper-express x 369 ops/sec ±2.72% (72 runs sampled)
express x 335 ops/sec ±3.12% (72 runs sampled)
Fastest: hyper-express
/api/album/get/GUb5qeQ1
hyper-express x 478 ops/sec ±3.41% (72 runs sampled)
express x 343 ops/sec ±3.59% (70 runs sampled)
Fastest: hyper-express
@BobbyWibowo
Copy link
Author

BobbyWibowo commented Jul 10, 2022

fetch-get.js.result is result of src/fetch-get.js in https://github.com/BobbyWibowo/perf-playground
Autocannon results are likely more reliable, since the tests performed with the aforementioned script will do them one-by-one in sequence (i.e. exactly 1 concurrent connection)
Nonetheless, even in that context we can see considerable performance improvement, so hyper-express simply wins all around

@BobbyWibowo
Copy link
Author

BobbyWibowo commented Jul 10, 2022

/api/check route is only a simple JSON response of some config options, so it's more of each web servers' actual performance, I'd think

/ route is also considerably faster because hyper-express branch comes with persistent internal cache for Nunjucks front-end pages

The other /api/* routes involve some DB queries, which are identical on both branches, so improvements came from the web servers alone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment