Get started Bring yourself up to speed with our introductory content.

How to successfully install Node.js applications on IIS

Microsoft's support for JavaScript engine Node.js applications on Windows Azure has brought the functionality to IIS. Here's how to set it up.

Node.js is one of the fastest-growing and most enthusiastically supported technologies for creating Web applications....

That, in turn, makes it a good match to deploy for an IIS installation. But the exact ways in which Node.js applications and Internet Information Services work together -- and on their own -- can make this installation a little tricky.

First, Node.js is not actually a Web server. It's a standalone engine for running JavaScript built with Google's V8, which uses an asynchronous, event-driven programming model. That said, many Node.js applications function as a Web stack.

Few such applications talk to the Internet directly because of the risks and the workload involved. Instead, any traffic to or from the Web at large is piped through a proxy of some kind -- Nginx, for instance, or Microsoft's own IIS.

For those with IIS programming experience, programmer Scott Hanselman has a useful analogy to describe how Node.js works in conjunction with IIS. He likens it to "an IHttpHandler written in JavaScript," which allows thousands of requests a second to be processed efficiently. This, of course, is the case if you know what you're doing with your code -- but that's for another day.

If you just want to run Node.js in a standalone fashion for the sake of development, that isn't hard: Launch the app in question and point a Web browser at it. Launching a deployment of a Node.js under IIS is another story.

Fortunately, Microsoft, which now takes Node.js pretty seriously especially on Azure, and some ambitious third parties have come up with solutions to host Node.js apps elegantly within IIS. The most fundamental and useful is iisnode, an open source project that takes the vast majority of the heavy lifting out of such integration.

The main benefit is that iisnode is a native IIS module, not a shim of some kind. It also handles many types of integration between a Node.js project and IIS, including the following:

  • IIS configuration management is used. Node.js projects are managed just like any other IIS site, so you don't need to use a separate management tool. Everything can be handled through IIS Manager.
  • Processes and process recycling are handled automatically. One common issue with Node.js happens if you update files for a Node.js project. You have to restart the Node.js process by hand to get the changes to take effect. Python apps under IIS, for instance, tend to suffer from the same problem.
  • It offers multi-core scaling. Node.js runs single-threaded and therefore on a single CPU core. Iisnode can create a Web garden out of multiple Node.js processes, so that incoming traffic can be load-balanced across each of them. Spawn as many processes as you have cores, and you'll be able to satisfy that many incoming requests at once. Note that this doesn't take into account the thread safety of your code -- that's your job.
  • It supports debugging via the node-inspector tool. Running an app in any stack isn't useful unless you have robust debugging tools; iisnode includes the node-inspector tool for detailed debugging work -- breakpoints, object inspection and much more.

Issues with hosting Node.js in IIS

A common complaint about hosting Node.js under IIS -- one which extends to many other language runtimes including .NET -- is how the first request to Node.js apps takes a long time to return a response. The first time such a request comes through, the Node.js instance has to be "spun up," which can sometimes take quite a lot of time if you have particularly complex Node.js applications. The creator of iisnode, Tomasz Janczuk, has some instructions on how to deal with this problem. Fans of clever solutions will appreciate this: It involves generating a fake request at startup, which is done entirely through IIS's configuration file for the site.

Another way to accelerate performance, often drastically, is to replace Node.js's own HTTP server with Windows and IIS's HTTP.SYS, as Janczuk explains. This means you don't have to add an extra layer of routing through IIS, although this comes at the cost of not having IIS's management features. Therefore, this should be considered an advanced exercise -- the kind of performance-optimization that should come later in the development cycle, not earlier.

Janczuk has also created Edge.js, a library that allows Node.js applications to talk to.NET within the same process. If you already have .NET libraries you've built for other projects and want to make your new Node.js project talk to them, this is one possible way to go. C#, F#, Python, T-SQL and PowerShell are all callable through Edge.js.

Finally, if you're building a Node.js project from scratch and are thinking about deploying it into the cloud, one way to do this with the help of Microsoft's framework tools is to use WebMatrix, Microsoft's free tool for Web development project management. It supports Node.js as a first-class component and you can deploy it to any hosting provider that supports it, including Windows Azure.

About the author:
Serdar Yegulalp has been writing about computers and information technology for more than 15 years for a variety of publications, including InformationWeek and Windows Magazine. Check out his blog at

This was last published in October 2013

Dig Deeper on Microsoft Internet Information Services (IIS)

Join the conversation


Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

I am aware that Microsoft has invested financially and with technology resources to enable Node.js to work more efficiently under Windows Server with IIS.

However several Web/Internet technology professionals, including director of Internet/communications technology at one of the largest publishing and Energy Research firms in USA has declared that Node.js performance and reliability as thoroughly tested under the Microsoft base remains marginal at best, and his company as well as most of the other Fortune 500 corporations Web operations about which he has some in-depth knowledge prefer to host their Web/internet infrastructure on RedHat Enterprise Linux with Apache or nginx HTTP/Proxy server.

On this last point, a senior technology developer with a tier one IBM Partner stated that any use of Microsoft IIS in Web services framework must also include some fairly secure and robust Proxy services such as Microsoft's Threat Management Gateway (TMG) or similar proxy/security services, not found in IIS alone. This further requirement by itself adds considerable costs - possible double or triple the original planned $dollar outlay - to any Web services project deploying Microsoft Windows and IIS.

Should not this critical aspect of Web deployment costs be included or at least mentioned in every article about IIS with Node.JS?
Good to see this information.. but this post not explaining it how to do it.. its saying that these are the ways to do it.. but not really explaining how to do it. similar kind of information available in many sites.. but no one is showing how to do it step by step and why a request routing is required ..if these are explained then only this post is most useful.