Thursday, September 29, 2011

Using Event Tracing for Windows to track and diagnose node.js applications hosted in IIS/iisnode

In my recent posts I talked a lot about iisnode which allows hosting node.js applications in IIS on Windows. In this post I will describe ways to track and diagnose failures in node.js apps deployed in IIS using Event Tracing for Windows (ETW) just integrated into v0.1.8 of iisnode. ETW is only available on Windows Vista and up and Windows 2008 Server and up.

What it is

Event Tracing for Windows (ETW) is a kernel mode logging feature in Windows with minimal performance overhead. ETW can be turned on or off at any time, even when the application is already running, using a set of tools included in Windows. You can read more about ETW and various ways of using here.

How to use ETW with iisnode

During installation of iisnode for IIS 7.x or IIS Express 7.x you will get a new script file that helps with capturing ETW traces for iisnode and generating viewable reports from them. The script is located next to iisnode.dll – in the IIS 7.x installation it is at %programfiles%\iisnode.

Consider calling ‘iisreset’ first to start capturing ETW traces starting from a clean slate. However, you can also perform the procedure when the IIS worker process, iisnode, and node.exe are already running in the system.

Start by running the etw.bar script from an administrative command prompt:

image

Then run your test scenarios you intend to capture ETW traces for. For example, navigate to the helloworld sample that ships with iisnode:

image

When you are done with your test scenario, go back to the command line running the etw.bat script and stop capturing ETW traces by pressing a key:

image

The script created the *.etl file with captured traces that can be post-processed with ETW tools. It also generated an XML report that contains human readable trace log. Press a key one more time and the XML file should open in your default application associated with the *.xml file extension (most likely your browser):

image

What is being traced

iisnode currently generates following ETW traces at three verbosity levels:

  1. Error
    • iisnode has failed to initialize the application manager
    • iisnode failed to create a new node.js application
    • iisnode failed to initialize a new node.js application
    • iisnode failed to initialize a new node.exe process
  2. Information
    • iisnode has initialized the application manager
    • iisnode initialized a new node.js application
    • iisnode initialized a new node.exe process
    • iisnode received a new http request
    • iisnode failed to process a new http reques
    • iisnode detected termination of node.exe process
  3. Verbose
    • iisnode found an existing node.js application to dispatch the http request to
    • iisnode has flushed standard handles of the node.exe process
    • iisnode dequeued a request for processing from the pending request queue
    • iisnode attempted to dequeue a request for processing from the pending request queue but the queue is empty
    • iisnode request processing failed
    • iisnode request processing succeeded

Under the hood

If you prefer using ETW tools on your own over invoking the included etw.bat file, you will need the iisnode ETW provider id, which is {1040DFC4-61DB-484A-9530-584B2735F7F7}.

Enjoy!

Tuesday, September 27, 2011

Current installation packages for node.js and iisnode for Windows

I have been working lately on the iisnode project to provide good support for running node.js applications on Windows. Since both node.js itself as well as iisnode version very frequently at this stage, I have set up a set of stable URL aliases that will always point to the latest installation packages. If you plan to create any web content related to running node.js on Windows (blogs, tweets) and you need to link to the installation packages, it is a good idea to use the links below unless you must attach to a particular version.

Here are the links:

node.js (x86): http://go.microsoft.com/?linkid=9784334
iisnode for iis7 express (x86): http://go.microsoft.com/?linkid=9784329
iisnode for iis7 (x86): http://go.microsoft.com/?linkid=9784330
iisnode for iis7 (x64): http://go.microsoft.com/?linkid=9784331

Enjoy!

Monday, September 26, 2011

High density server side JavaScript

I will be speaking about high density server side JavaScript at JSConf.EU 2011 next weekend. Here is the abstract:

Cloud computing reduces the cost of running applications with economies of scale. Major factor in this cost reduction is the granularity of assigning computing resources (CPU, memory, network) to competing applications. Physical machines, virtual machines, and OS processes have been successfully used to provide isolated quantities of computing power at decreasing levels of cost. Pushing the granularity of computing power to sub-process level would allow offering shared hosting plans at a fraction of the cost possible today. Server side JavaScript is an ideal solution to support sub-process application density in a multi-tenant environment. It yields itself very well to sandboxing applications and controlling the use of computing resources. This talk explores the limits of application density and therefore cost reduction of running server side JavaScript code using a variety of approaches.

image

Thursday, September 15, 2011

Getting started with node.js on Windows

Here are a few quick steps to set up a node.js development environment on Windows:

  1. Install WebMatrix: http://www.microsoft.com/web/webmatrix/
  2. Install node.js: https://github.com/tjanczuk/node/downloads
  3. Install iisnode for IIS Express (choose x86 even on 64 bit systems): https://github.com/tjanczuk/iisnode/downloads 
  4. Install Steve’s node.js templates for WebMatrix: https://github.com/SteveSanderson/Node.js-Site-Templates-for-WebMatrix/downloads 
  5. Open WebMatrix, choose “Site from folder”, enter %localappdata%\iisnode\www, start the site, and play with the iisnode samples, or
  6. Use node.js templates to get started quickly with an Express application or a skeleton Hello World

For more information and howtos check out my recent posts and visit http://github.com/tjanczuk/iisnode.

I hope you like it and I am looking for your comments and suggestions. Please report any issues at https://github.com/tjanczuk/iisnode/issues.

My Photo
My name is Tomasz Janczuk. I am currently working on my own venture - Mobile Chapters (http://mobilechapters.com). Formerly at Microsoft (12 years), focusing on node.js, JavaScript, Windows Azure, and .NET Framework.