Node.js 10 is the LTS the enterprise will love!

Is October 2018, when the long run for a new Node.js LTS version is getting to an end. In this article, I would like to share with you a set of “pragmatic” performance tests, comparing older LTS branches in terms of “speed of execution”; as well as the coolest features available.

Keep reading and enjoy, what is in my opinion: the fastest and the greatest Node.js version till now.

Node.js 10 coolest features (top 3)

N-API

N-API (pronounced N as in the letter, followed by API) is an API for building native Addons. It is independent from the underlying JavaScript runtime (ex V8) and is maintained as part of Node.js itself. This API will be Application Binary Interface (ABI) stable across versions of Node.js. It is intended to insulate Addons from changes in the underlying JavaScript engine and allow modules compiled for one major version to run on later major versions of Node.js without recompilation. The ABI Stability guide provides a more in-depth explanation.

You can checkout a basic example using the N-API in this github repository: https://github.com/mafintosh/a-napi-example/blob/master/a_napi_example.c

Also read more about this topic here: “Node.js Removes Version Dependencies for Native Modules

HTTP2

Node.js v10 LTS brings in a native, stable HTTP2 support!
Meaning developers can take control over the biggest HTTP protocol update.

Pros

Workers/Threads (yet experimental)

If there was something impossible to do in Node.js before: those were intensive CPU tasks!
In Node.js 10, although yet in experimental status, we have the opportunity to use real worker/threads that will allow us to perform CPU intensive operations: the puzzle is now completed!

NOTE: We exclude I/O operations in here, as they were always highly optimised and natively multi-threaded by the Node.js engine.

The worker module is accesible under the flag: — experimental-worker. Let’s evaluate a complete example using the microjob👏 npm package:

Node.js 10 performance does impact!

DISCLAIMER: Benchmarking it’s a science, the results presented here are just practical impressions using out of the box technologies without any tweak or optimisation.


The test machine

MacBook Pro 2016 (2,7 Ghz Intel Core i7, 16GB RAM — LPDDR3)

Google Octane 2 Benchmark Tool

Couple of years ago the Octane 2 tests suite was a reference as a performance measurement tool, used by major browser’s vendors like Mozilla, Opera, Microsoft or Google.

Back in those days, if you wanted to show up with your Web browser release you had to present the Octane 2 test score…

Nowadays, it is not so relevant or accurate anymore, because JavaScript applications requirements has become much more sophisticated (read v8 team note about it). However, by comparing the different Node.js LTS versions score on this tests we can clearly see how performance is improving for every LTS release branch.

The classic HTTP “Hello World” service

“When using Node.js, REST based micro-services are first class citizens.”

Here I want to show how HTTP services respond to heavy load using different Node.js frameworks implementation. The wrk tool is used for the benchmarks, 8 threads and 100 concurrent connections producing high load for 5 seconds against a single threaded HTTP service…

REST API + ASYNC + JSON

Here a basic express based REST API simulate asynchronous load with JSON payloads:

The “ABC” arrays operations

Arrays management operations in Node.js enterprise applications are kind of mandatory, next, the most used operations are evaluated. In the following benchmark we measure the speed of execution:

Conclusions

Node.js 10.x branch is almost marked as LTS and the enterprise is waiting for it: Welcome HTTP2, Workers/Threads, N-API, performance improvements and more! 👏👏👏👏

sharenowTech

SHARE NOW TECH Blog

Rolando Santamaria Maso

Written by

ENTHUSIASTIC AND PASSIONATE COMPUTER SCIENCES ENGINEER. CURRENTLY A NODE.JS CHAPTER LEAD AT SHARE-NOW…

sharenowTech

SHARE NOW TECH Blog