Node 0.6.x and the code in Node Web Development

Date: Wed Jun 14 2017 Node Web Development
Node 0.6.x came out a month or so ago, and befitting a software platform with a 0.x version number it came along with a slew of API changes.  The API changes are positive and great, and I'm sure there will be a few misfortunate people on Windows who will appreciate that Node is now running native on that operating system.  In any case on a more direct level to me was the worry of whether the API changes would break the code in my book, Node Web Development (see link in the sidebar).

I'm happy to report that all the examples in the book still work with 0.6.2 on my laptop (Mac OS X).  Whew!

That is, except for the examples which use the LearnBoost cluster package to manage multiple processes. 

Let's first back up a sec and go over the thing "cluster" is trying to solve.  In the book I had this fun-to-write section in one chapter where I spun a picture of your manager getting upset because the new Node.js app you'd written only uses one core of the shiny new 32 core server you bought to run the app on.  The "cluster" package gave you a solution for this by giving you a way to manage multiple child processes from a simple API.

This issue stems from the Node design principles.  A single execution thread, and no threading period.  That means your Node process will run on one core, period.  That puts "scaling" as an issue you have to solve right away in your application, how do you scale to use multiple cores and/or multiple servers. 

In any case coming along with Node 0.6.x was a new core package named "cluster".  You access it with "require('cluster')" which means the existing cluster package is now squeezed out by the core package of the same name.  Not only that, but the 0.6.x cluster package had a different API from the LearnBoost cluster package.  I see on the github page for the LearnBoost cluster package that they claim support for 0.2.x and 0.4.x but not 0.6.x.  Hmmm..

Fortunately for my book the use of the LearnBoost cluster package was limited to one example at the beginning, and you can skip right over it if you like.

I think, though, that I'll explore using the new cluster package and post something about it soon.