Categories
Posts

Live Updating a Node.js Web Server

Each time I look at Node.JS the issue of live updating comes up. For PHP it is easy to take live updating for granted. You update your .php files and *poof* your site is running the new code. With the merged web server model of Node.JS that doesn’t happen.

I’m happy to see some folks thinking along these same lines. From Staying up with Node.JS:

To many beginner Node.JS users, a fundamental and immediate apparent disadvantage of writing their web applications with Node.JS lies in the inability to save a file, refresh the browser and see their changes live.

This isn’t just a beginner issue though, it make deploying to production much more complex as well:

The need for seamless code reloads extends into the realm of production deployment as well: one needs to be able to serve new requests with fresh code immediately, without breaking existing ones (such as file uploads or content transfer).

To deal with these issues LearnBoost has developed two projects: distribute and up.

Another option that has been brought up is hotnode, which looks like a fairly simple approach. In general the fewer moving parts the better.

If you are using Node.JS for production services, what approach do you use for deploying updates? Are you doing a load balancer and worker dance (spin up new worker, add it to load balancer pool, drop out an older worker, update it, add it back to the pool) or have you come up with a live update method?

2 replies on “Live Updating a Node.js Web Server”

Something I failed to emphasize in my article is that unlike most hot core reloaders, `up` ensures the existing requests keep running and complete, and new ones go towards the new code.

This is something `hotnode` can’t possibly do, since it doesn’t have knowledge of what the process is doing (for example, if it’s transferring HTTP requests).

`hotnode` could still be good for development where you don’t care so much for not dropping requests, even though in my experience it’s still not as pleasant.

Leave a Reply

Your email address will not be published. Required fields are marked *