Node.js REST Frameworks Benchmarks – reloaded (09/08/2019)

I just got the new MacBook Pro 2019 and damm, it is a crazy fast laptop. Thanks to ShareNow Tech for offering such a tools to employees…

A detailed performance review for the Macbook Pro can be found here: https://www.laptopmag.com/reviews/laptops/2019-macbook-pro-15-inch)

Second thing after celebrating and setting the Node.js development environment up, was to measure the I/O performance of the following REST frameworks on their last stable version:

  • Vanilla Node.js
  • Koa
  • Express
  • Fastify
  • 0http (with uWebSockets.js)
  • Restana
  • Polka

NOTE: Network throughput is not the only factor that matter while selecting a backend framework, if you don’t care about low level performance optimisations, is just fine!

Out of the Box tests, single threaded “Hello World” HTTP services

In this tests the services are running using a single process, the Node.js cluster mode is not used for the HTTP Servers.

The tests sources can be found in the restana github repository: https://github.com/jkyberneees/ana/tree/master/performance, see performance/{framework}-minimal.js

wrk as benchmarking tool

We use the wrk benchmarking tool with the following configuration:

wrk -t4 -c60 -d5s http://127.0.0.1:3000/hi

Node.js version

v10.16.2

Test Results

Some highlights:

  • express is like the “honeybadger”, it doesn’t give a f… on hardware performance, it just eat it all ;(
  • restana remains performing top on the list of native Node.js frameworks.
  • By using an uWebSocket.js based HTTP Server wrapper, 0http clearly outperforms here.

For more details, the raw wrk results for every framework is printed below:

0http + uWebSockets.js

wrk -t4 -c60 -d5s http://127.0.0.1:3000/hi
Running 5s test @ http://127.0.0.1:3000/hi
  4 threads and 60 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   413.89us   80.29us   3.01ms   90.32%
    Req/Sec    36.39k     1.80k   38.25k    91.18%
  738593 requests in 5.10s, 76.07MB read
Requests/sec: 144822.07
Transfer/sec:     14.92MB


Express

wrk -t4 -c60 -d5s http://127.0.0.1:3000/hi
Running 5s test @ http://127.0.0.1:3000/hi
  4 threads and 60 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.44ms  340.20us   9.40ms   88.51%
    Req/Sec     6.18k   340.40     6.62k    77.45%
  125502 requests in 5.10s, 25.85MB read
Requests/sec:  24604.33
Transfer/sec:      5.07MB

Fastify

wrk -t4 -c60 -d5s http://127.0.0.1:3000/hi
Running 5s test @ http://127.0.0.1:3000/hi
  4 threads and 60 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.07ms  173.85us   6.41ms   89.58%
    Req/Sec    14.14k   773.45    15.27k    86.76%
  287013 requests in 5.10s, 41.88MB read
Requests/sec:  56267.86
Transfer/sec:      8.21MB

Restana

wrk -t4 -c60 -d5s http://127.0.0.1:3000/hi
Running 5s test @ http://127.0.0.1:3000/hi
  4 threads and 60 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   793.93us  239.77us   3.53ms   91.92%
    Req/Sec    19.14k     1.02k   23.48k    76.35%
  386661 requests in 5.10s, 41.30MB read
Requests/sec:  75807.54
Transfer/sec:      8.10MB

Koa

wrk -t4 -c60 -d5s http://127.0.0.1:3000/hi
Running 5s test @ http://127.0.0.1:3000/hi
  4 threads and 60 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.56ms  210.25us   5.73ms   88.08%
    Req/Sec     9.66k   566.00    10.31k    84.80%
  196065 requests in 5.10s, 28.61MB read
Requests/sec:  38442.57
Transfer/sec:      5.61MB


Native

wrk -t4 -c60 -d5s http://127.0.0.1:3000/hi
Running 5s test @ http://127.0.0.1:3000/hi
  4 threads and 60 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     0.87ms  117.82us   3.65ms   89.99%
    Req/Sec    17.34k   589.95    18.57k    74.02%
  352162 requests in 5.10s, 37.61MB read
Requests/sec:  69043.86
Transfer/sec:      7.37MB

Polka

wrk -t4 -c60 -d5s http://127.0.0.1:3000/hi
Running 5s test @ http://127.0.0.1:3000/hi
  4 threads and 60 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.02ms  152.72us   4.07ms   88.40%
    Req/Sec    14.77k     0.95k   19.46k    88.67%
  298469 requests in 5.10s, 31.88MB read
Requests/sec:  58528.27
Transfer/sec:      6.25MB

One thought on “Node.js REST Frameworks Benchmarks – reloaded (09/08/2019)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.