/Node-Express-Cluster-Tutorial

A simple demo showing the power of the Node cluster module

Primary LanguageJavaScript

Node-Express-Cluster-Tutorial

A simple demo showing the power of Node's cluster module.

  • With just a few lines of code you can significantly increase the performance of your Node/Express applications!
  • server-basic.js contains a minimalist Node/Express server
  • server-cluster.js contains the same server forked using the Node cluster module.

Testing server performance

  • You can compare the performance of each server with Siege, an awesome HTTP load testing utility.
  • The below comparison was generated using the siege command siege -b -c 255 -t 15S http://localhost:3000

Setting up the repository/running performance tests yourself

  • Use npm install to grab the required node modules
  • Install the Siege command line tool by following the steps outlined in this blog post
  • Run the basic server via npm run basic
  • In another terminal window, test the server's performance via npm run siege or create a custom siege test of your choosing
  • Once the test is complete, shut down the basic server and run the cluster server via npm run cluster
  • Test the cluster server with the same test you ran on the basic server
  • Once the second test is complete, you can compare each servers' performance via the terminal log or view more detailed log results from Siege in /usr/local/var/siege.log

Further Reading