Step-by-Step Node.js Guide for Realtime Monitoring and Scaling

OpenShift Partner Nodefly LogoNodeFly allows you to monitor and visualize CPU load, response times, top HTTP requests, concurrent connection counts, and more.

If you are new to NodeFly, David Whiteley has an excellent introduction available in a previous post, and a nice follow-up on scaling as well.

Our quickstart guide and sample application, includes notes on how to add NodeFly Realtime monitoring to any existing Node.js app.

In this post, we’ll provide step by step instructions for scaling and monitoring your application cluster on OpenShift.

“Support for Realtime monitoring of Auto-Scaling Applications has arrived!”

These notes should allow you to spin up your own clustered nodejs sample application, complete with realtime monitoring, all in a matter of minutes:

Step 1 – Sign up for OpenShift and Nodefly

I’ll be using OpenShift Online for this post. A free tier is available here:

NodeFly also has a free plan available, sign up here:

Note: If this is your first time with OpenShift, make sure that you install and configure our command-line tools before proceeding.

Step 2 – Deploy your own instance of the OpenShift Nodefly quickstart

After installing the command-line tools, this task can be done in a single step:

rhc app create -s nodefly nodejs-0.6 --from-code git://

The above command will create a new application named “NodeFly”, based on the source code from the supplied repo address. For detailed instructions on creating applications from the command line, type rhc help app create.

Including the -s flag will produce an application that is configured to be run in a scalable / clustered mode.

This step is also possible via the web-based interface, but the command line will provide an easier way to quickly configure our application’s NodeFly application key.

Step 3 – Set your NodeFly Application Key

After creating a NodeFly account, you should be able to find your Application Key at the bottom of your NodeFly Account Settings.

Enter your application source folder to configure your key:

cd nodefly # or whatever your named your app

Open up your server.js file, and set your application key in your app’s NodeFly configuration area:

var app_name = process.env.OPENSHIFT_APP_NAME || 'local_development',
    host_url = process.env.OPENSHIFT_APP_DNS  || 'localhost',
    gear_id = process.env.OPENSHIFT_GEAR_UUID || 1,
    options = {};
  '00000000000000000000000000000000000000000', // <-- enter your nodefly dev key
  [ app_name,                                  // See 
    gear_id], // to identify multiple gears or processes (for scaled apps)
  options // optional

Step 4 – Deploy your changes

git add server.js
git commit -m 'Setting my NodeFly application keys'
git push

That’s it, you can now visit your sample application at:


If your update was successful, realtime metrics for your application should appear in your Nodefly Dashboard.

Final Step – Scale Up!

OpenShift will automatically scale any applications that are configured to be part of a scaled group. You can trigger this scaling operation by sending a sufficient number of network requests to your application hostname.

Setting a minimum gear count for your scaled application is another way to ensure that your app is operating in a multi-gear mode.

Use the OpenShift application dashboard to set your clustered application’s minimum scale to two or three gears.

Application scaling settings

Pro Tip: This page also provides a link to your application’s HA-Proxy status page:

After scaling up your application cluster, you should be able to review metrics from each application instance in your scaling cluster / group by selecting them from a dropdown menu on your NodeFly Dashboard page:

monitor mulitple processes in a clustered app

Thanks for following along!

What’s Next?

Comments are closed.