This guide explains how to use the N|Solid Console with applications made with express, and the cluster modules.


Please refer to our Quick Start Guide for instructions on how to install the latest version of N|Solid.

This example application uses the module that requires a redis server running, you can run it locally:


Now you can run your own application.

The application is a simple Express + application, using the cluster module and running multiple workers. The source code is:

File index.js

const http = require('http')
const cluster = require('cluster')
const path = require('path')
const express = require('express')
const sio = require('')
const RedisStore = require('')

const port = process.env.PORT || 3000
const numCPUs = require('os').cpus().length

if (cluster.isMaster) {
  var workers = []

  // Helper function for spawning worker at index 'i'.
  var spawn = function (i) {
    workers[i] = cluster.fork()

      // Optional: Restart worker on exit
    workers[i].on('exit', function (worker, code, signal) {
      console.log('respawning worker', i)

  // Register some callbacks to if any worker is ready or die
  cluster.on('fork', function (worker) {
    return console.log('forked worker ' +

  cluster.on('listening', function (worker, address) {
    return console.log('worker ' + + ' is now connected to ' + address.address + ':' + address.port)

  cluster.on('exit', function (worker, code, signal) {
    return console.log('worker ' + + ' died')

  // Spawn workers.
  for (var i = 0; i < numCPUs; i++) {
} else {
  const app = express()
  const server = http.createServer(app)
  const io = sio.listen(server)

  io.adapter(RedisStore({ host: 'localhost', port: 6379 }))

  // At the root of the server answer with client code
  app.get('/', function (req, res) {
    // see below the index.html content
    return res.sendfile(path.join(__dirname, '/index.html'))

  io.sockets.on('connection', function (socket) {
    // We can see wich worker use the socket connection
    console.log('socket call handled by worker with pid ' +

    // Just send some data to client.
    return socket.emit('news', {
      hello: 'world'

  // start our server

File index.html

<script src="/"></script>
  var socket = io();
  socket.on('news', function (data) {
    socket.emit('my other event', { my: 'data' });

You can run it using this command:

$ NSOLID_COMMAND=9001 nsolid index.js


You should now see the N|Solid console overview with all the general data of the application.


The cluster view displays a dot in the graph for each worker. Clicking on a dot will provide more detailed information about that worker.