Node.JS Best Practices And More - My Two Cents

During the last few months I've been working mostly on Node.JS projects so I've been reading and trying new things all the time.

Following a couple of blog posts that I've read recently about Node.JS best practices and things you shouldn't do in Node.JS (links will follow soon) I wanted to add a couple of more points that I've gathered along the way.

Node.JS best practices: http://blog.risingstack.com/node-js-best-practices/

7 things yout should stop doing in Node.JS: http://webapplog.com/seven-things-you-should-stop-doing-with-node-js/ 

To "Forever" or not to "Forever"?

There's a paradigm I've noticed in Node.JS that the server should stay "live" forever, this in turn mean that critical error may be "swallowed" by a mehcnism like "Forever". A nice different approcahes may be found here:

* Handle un-expected errors in your Node.JS server by letting it crush and then restarting it: http://shapeshed.com/uncaught-exceptions-in-node/

Child Process

Node.JS runs on a single thread but there are ways to spawn some of it's activities into child processes. I recently developed an extention to the project I'm working on that spawns all the network activities into a child process, thus, improving the overwhole efficiency of the server.

* Move tasks into child process: http://www.andygup.net/node-js-moving-intensive-tasks-to-a-child-process/



Share this article: