rohankangale2011 / node-clustering

Clustering in node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-clustering

Performing clustering in nodejs application in order to improve your server's performance/response.

Quick start

Run the following commands once you clone the repo:

npm install
npm start

Make sure that all the dependencies are installed and after running npm start, you see a console saying "Listening on port 3002". You can change the port as per your convenience.

Description

Node.js runs on a single thread, resulting to be faster in most of the cases. Although node couldn't take the advantages of the multiple processes(made available by the system). With clustering, a node application can create a small network of processes and gain the full power of your server/system.

Features

  • [Node] - Server running on node
  • [Express] - Nodejs framework for interacting with request/response from the web/front-end
  • [cluster] - Node module cluster for implementing clustering in the node application
  • [siege] - Node module for the performance testing of the application

Once the application is up and running, it's time to check the benchmark of the application. Use npm run siege for getting the performance output.

Result

Below is the result obtained by running application with and without clustering:

without clustering

> node@1.0.0 siege D:\rohan\node
> node performance.js
  starting node index.js
  GET:/
    done:1000
    200 OK: 1000
    rps: 1084
    response: 312ms(min)    690ms(max)      502ms(avg)

  GET:/get
    done:1000
    200 OK: 1000
    rps: 1447
    response: 69ms(min)     675ms(max)      504ms(avg)

with clustering

> node@1.0.0 siege D:\rohan\node
> node performance.js
  starting node index.js
  GET:/
    done:1000
    200 OK: 1000
    rps: 745
    response: 16ms(min)    1002ms(max)      283ms(avg)

  GET:/get
    done:1000
    200 OK: 1000
    rps: 1014
    response: 0ms(min)     754ms(max)      495ms(avg)
    response: 47ms(min)     47ms(max)      47ms(avg)

You can gather more information about node clustering from Node Clustering and siege from Siege.

Note: You might see some error's while running the npm run siege command. In order to resolve those, you need to stop your nodejs server(if it is running), as siege will be using the same port for the performance testing.

About

Clustering in node


Languages

Language:JavaScript 100.0%