News for hackers. Stuff that matters.
Re:Mistakes Node.js Developers Make by lost_my_pwd on Saturday January 03, 2015 @11:46AM (#8831163)
You can use Node's cluster API[1] directly or use a wrapping module such as Recluster[2]. With these, node will spawn a few children that get replaced when they die or time out (a little extra code is needed for the latter).

One can even do rolling upgrades with this for zero downtime releases.

If there is a known workload that will block for a while, one could 1) run the work in a child process, 2) consider using streams to process the data in chunks, or 3) break the work up by chaining smaller operations using "process.nextTick" to put the next operation at the end of the event loop (allows other pending operations to resume before continuing the slow/blocking work).

[1] http://nodejs.org/api/cluster.html [2] https://www.npmjs.com/package/recluster

There are no comments on this comment yet.