Using N|Solid runtime from NPM - NodeSource

The NodeSource Blog

You have reached the beginning of time!

Using N|Solid runtime from npm

First, a refresher, what is the N|Solid runtime?

At times, Node.js can feel like a black box. Shifting to an asynchronous programming model changes how developers are required to handle and interpret existing data.

There are many solutions out there to help the users gain more visibility; however, it has been proved that all those solutions out there to capture such critical information come with a high toll on the performance of every application implementing them. For more information check this benchmark and understand the problem reading this article.

We created the N|Solid Runtime to solve such a critical problem. The N|Solid Runtime is a build of Node.js bundled with an advanced native C++ component, the N|Solid Agent. The N|Solid Agent runs on its own thread inside the processes, with direct access to the core elements and statistics of Node.js, libuv, and the V8 JavaScript engine.

It follows a different approach than most tools by listening directly to the Node.js core components with almost no noticeable performance impact to generate the same information and even more Node.js specialized metrics. The other tools usually inject more code to be executed to get the insight needed, and the information obtained is not as comprehensive or specific for the Node.js case.

The N|Solid Runtime allows users to control their application behavior in production and provide advanced diagnostic tools that are available only in development environments using the regular Node.js runtime.

For example, with the N|Solid runtime, it is possible to capture CPU profiles and heap snapshots. These instrumental assets can diagnose and solve complicated performance issues unique to Node.js applications. It also bundles a powerful security policy model that allows real-time monitoring of vulnerabilities in the application dependencies. Hence, the user gets the information on time when their processes are at risk.

Some history on the N|Solid runtime

Historically, N|Solid runtime was just available to the big enterprise using Node.js, which was the product's initial target. It has been helping big brands to have high-performance observability and solve highly complex performance issues, so, initially, the setup process was designed for their internal policies and procedures with an on-premise solution.

The context of the platform changed dramatically last year when NodeSource launched a SaaS offering for individuals and small and medium companies. The SaaS platform took away the time and resources needed to have an N|Solid Console running. The N|Solid Console is a web application where the N|Solid runtime sends the monitoring information for inspection and analysis.

Even with the SaaS offering available, the N|Solid runtime still required a more complicated process for the new user's niche we were opening our solution. We launched a new way to set up the N|Solid runtime more straightforward to their use cases to make things easier.

From now on, a new valid way to consume the N|Solid runtime is supported and is very familiar to everybody; it could be used by installing it as a dependency from the NPM registry, the same as all the regular dependencies.

How does it work?

Currently, this module supports Linux, Windows, and Mac (for M1 Macs, it would require Rosetta) and requires a Node.js LTS version, as those are the ones available for the N|Solid runtime.

The NPM module, when installed, downloads the latest version of the N|Solid runtime matching the current Node.js LTS used in the local Node.js installation. The download happens at the postinstall process of the module; then, it proceeds to extract and put the runtime files at the current user's home directory inside a folder like .nsolid-runtime/nsolid-fermium to be used later by an NPM command.

The module includes a command called nsolid, which should replace the node command inside an NPM script and execute the original task using the N|Solid binary previously downloaded at the postinstall phase.

To use it, here are the steps:

Step 1: Install the module using NPM:

$ npm install nsolid

Step 2: Modify or create an NPM script at the package.json to launch the application with N|Solid like:

  "scripts": {
      "start": "nsolid index.js"
   },

Step 3: if you don't have an account, sign up for a free N|Solid Console at our SaaS service here; after having one, access your dashboard to get your SaaS token.

02-saas-console-url full

Step 4: Connect a Node.js app to an N|Solid Console; there are two options to accomplish this:

  • Setting the environment variable NSOLID_SAAS to a SaaS token acquired at the previous step
  • Modifying the package.json to include the permanent configuration for the application like this:
"nsolid": {
  "saas": "HERE_PUT_YOUR_SAAS_TOKEN"
},

Step 5: Now that everything is configured, execute the NPM script to start sending the monitoring info to the N|Solid console; in the previous example, it would be like this:

$ npm run start

Step 6: After running the application, visit the N|Solid Console to start analyzing and monitoring the process. Go back to the NodeSource account; the URL will be there to be accessed.

Conclusion

It has never been this easy to get insight into your Node.js applications by following a simple process and, most importantly, not including a prohibitive performance cost to get the information you need to solve your problems.

One thing to notice is that the code for the nsolid module is Open Source and is available at this repository. However, the N|Solid runtime is free to use, but it is proprietary software.

About NodeSource

NodeSource is a technology company dedicated to delivering enterprise-grade solutions in support of a sustainable ecosystem for the open source Node.js project. We aim to drive and expand the Node.js ecosystem by providing best-of-breed solutions that specifically target the needs of businesses deploying Node.js and JavaScript at scale. Customers include PayPal, Condé Nast, Delta Airlines, Mastercard and other progressive Node.js adopters.
For more information, visit NodeSource.com and follow @NodeSource on Twitter.

The NodeSource platform offers a high-definition view of the performance, security and behavior of Node.js applications and functions.

Start for Free