Why is YouTube app not installing?
If you're not familiar with node.js, it's a new web programming toolkit that everyone's talking about. It's the one that makes you feel not hip if you don't know what it is. Like Ruby on Rails was a few years back. Folks called it "Node" and it's basically server-side JavaScript. The idea is that if you are doing a bunch of JavaScript on the client and you do JavaScript all day, why not do some JavaScript on the server also. One less thing to learn, I suppose. Show If you are an ASP.NET programmer, you can think of node.js as being like an IHttpHandler written in JavaScript. For now, it's pretty low-level. It's NOT an HttpHandler, but I'm using an analogy here, OK? Here's a lovely article by Brett McLaughlin that goes into more detail about Node.js and what it is. His subtitle is "Node isn't always the solution, but it does solve some important problems" and that's just exactly it. UPDATE 1: Why does node.js matter?Why bother with node at all? There's a number of interesting aspects to node as it sits. It uses a very fast JavaScript engine called V8, but more importantly its I/O is asynchronous and event-driven which contrasts with typical synchronous code. For example, a naive hello world HttpHandler in ASP.NET that "does some work" for a few seconds (gets a file, accesses a service, etc) could look something like this: public class SimpleHandler : IHttpHandler And this is usually fine for most stuff. However, when I push this HARD with a load testing tool and a thousand virtual clients, I can barely get 60 requests a second. The request thread is tied up waiting for the "work" to happen and everyone else gets in line. I'm using up ASP.NET pool. It'd be nice if the work would get handled and someone would "call me back" when it's finished. It's like waiting on hold for tech support. You are effectively blocked as you wait for them to pick up their end. Wouldn't it be nice if they just called you back when they were ready? ASP.NET has always been able to do things (see this MSDN article from 2003 on Async Handlers) with IHttpAsyncHandler but it's always been a bit hard and almost no one knows about it. With the Async CTP and the Task libraries built into .NET, you can build a nicer abstraction on top of IHttpAsyncHandler. Ayende has a simple example AbstractAsyncHandler (there's many of these out there, including a few in our own tools, some things in MVC, and some things in SignalR (more on that soon)) that we can use to do similar work. This example could also do other more complex and pertinent things like file IO, db IO or calling a web service. This is a naive example that doesn't map exactly to the node one below, but it makes the point. Plus, it's nice to look at. public class SimpleAsyncAyendeHandler : AbstractAsyncHandler Pointing the same 1000 virtual clients at this handler gives me 500 requests a second, which makes sense as a request takes 2 seconds to finish. If we were doing I/O or other more complex and long running things than waiting, this scales better than the first example. Doing asynchronous code in .NET as well as parallelism is much easier than before, as evidenced by the two lines of code above and the simplicity of Ayende's small example. The fact that this kind of thing is easy and elegant in node is an attractive thing about node. Node loves asynchrony, and uses JavaScript callbacks to provide asynchrony in a pleasant way. You use events and callbacks in JavaScript already on the client, why not use them on the server? Here's an example from Marc Fasel's blog on the topic. First, some synchronous file work via Marc: var fs = require('fs'), filenames, i, processId; And the same work using an asynchronous pattern that may look familiar! var fs = require('fs'), processId; The I/O happens and the callback function that's dependant on the result is executed when the I/O is finished. Powerful stuff. Why would I want node.js to run on Windows and IIS?Tomasz Janczuk is working on the iisnode project lately. You might think that Windows and node don't belong together. "That's just wrong! What are they thinking? I thought IIS was all about .NET?" Well, you may recall I spoke at CodeMash a few years back on IIS7 and PHP and did a screencast showing how IIS7, PHP and FastCGI could push many thousands of requests a second. The IIS folks, the Windows folks, the Azure folks, want to make sure everything runs well on Windows. Remember, we sell Windows, so it's good if it does many things well. ;) Why bother getting node to run on IIS? Tomasz says it best:
These are all compelling, but the most interesting bit here, in my opinion, is integration. The iisnode module is a proper IIS module, just like ASP.NET and PHP. This means you can have a single website that has multiple kinds of content. Restated from above:
Sometimes folks freak out when I say you can have an ASP.NET WebForms app and a ASP.NET MVC app in the same AppPool as a "hybrid." Frankly, Dear Reader, people don't even realize the power and flexibility of IIS. When you plug in something new like node but run it the way you run other things it inherits all the coolness of the outer container, in this case, IIS. Fine, you got me, how do I run node.js on Windows?I'm assuming you are running IIS7.
The install.bat will:
No warranties! Be careful, you're living on the edge. Remember, you're reading this stuff on some random dude's blog. WARNING: I couldn't figure out the right permissions for the AppPool and the File System so I wimped out and gave my local AppPool "SYSTEM" permissions. This is awful and totally my fault. I filed an issue on the iisnode GitHub and I'll fix it and update this post when I hear back. I made a new AppPool just for node, gave it SYSTEM access, then assigned the Node Site to this new AppPool. Your site should look like: And if you click on Modules for this Site in IIS7 you should see iisnode as a native module: At this point, you should be able to hit http://localhost/node/helloworld/hello.js and get back: Hello, world! [helloworld sample] The contents of which are simply: var http = require('http'); Lovely. Fooling around with WCAT (Web Capacity Analysis Tool) and node.Disclaimer: To be clear, this is so very fooling around. This is just to show that it works and it can do the basics really fast. I'm not doing a benchmark nor am I saying "this works better than this other thing." Remember, they just got started recently porting node itself to Windows, and Tomasz and friends are just beginning their work. So, don't overreach. That said, the preliminary work they are doing is really impressive. I couldn't help myself. I mean, it's one thing to install a helloworld of some new thing, run it once and go "OK, that runs." It's another to pound it until it says "Uncle." After I got the hello world stuff working, I wanted to do some poor man's stress testing to see what the players involved did. First, I installed WCAT, a free Web Capacity Analysis Tool from the IIS team.
Warning. This is a command-line only tool and it's really persnickety when you run it. It's confusing and it took me a minute to setup. Here's the steps I took after installing. This is all from an Administrator Command Prompt. Note also that I'm doing this all on one machine, which is cheesy, but remember, it is a GOM.
wcat.bat pushd C:\Users\Scott\Desktop\nodetests nodescenario.ubr (or call it whatever you want) This is so basic. It just beats on the four sample applications for a while. scenario settings.ubr I just copied in the one from samples and uncommented out and changed (and tweaked during testing) these lines: server = "hexpower7"; Now, run the Test Next, I ran wcat.bat as an Administrator...you can see all the little node.exe's firing up. I've got a (Remember they are running as SYSTEM because I was unable to figure out the right permissions. That's my bad, no one else's. I'll figure it out one day.) Here's the WCAT tool's console output...I'm able to consistently do 10,000 hello worlds a second and ended up with just under a million normal requests and responses in 90 seconds. That's a lot of hello worlds. Remember Hanselman's Rule of Scale.
Of course, this is all local on a fast machine. This is just hello world (with some logging) so it's not testing node much, nor IIS much, but rather the collaboration between the whole system, IIS, iisnode, and node itself.
Here's the node/iisnode results: There's a lot of things I could configure on both sites, number of clients, virtual clients, as well as iisnode-specific settings (which are, nicely enough, managed in a web.config:
This is pretty cool stuff. I like that the team I work with is excited to make things work well on IIS and I'm stoked that I can mess around with node now without firing up VMs. I'll report back as I learn more! Related Links
About ScottScott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author. About Newsletter Hosting By Comment on this post [59] Share on Twitter or Facebook or use the Permalink August 28, 2011 13:25 Just tried WCAT. It sometimes (I ran the same script multiple times...) omits the summary after "Finished collecting statistics". Meh. How do I fix that? It's a nice tool, much better than Apache bench on Windows. Jabe August 28, 2011 13:34 This is what I have been waiting for. Thank you so much :) Joel Alenchery August 28, 2011 13:36 Jabe - Dunno. Can't you look in it's logs, that's where the report/results will be. Scott Hanselman August 28, 2011 14:07 Pretty Cool! Now we just need a reliable way to connect to mssql. Mike August 28, 2011 14:57 I had been wondering why iisnode existed, and this post explains it. Thanks. Mark Rendle August 28, 2011 15:46 Will iisnode accept contributions from outside MS? I know that was a big deal with Nuget, hope we're still moving in the right direction... Keith Dahlby August 28, 2011 17:03 @Scott - I've found a similar question on serverfault here: http://serverfault.com/questions/26062/web-capability-analysis-tool-wcat-no-output-xml Jabe August 28, 2011 18:57 Very useful post, thank you Scott :). Serhiy Shumakov August 28, 2011 19:17 @Mark try ryppi instead of npm, its not as fancy and requires python but gets the job done without having to install cygwin on windows. abombss August 29, 2011 3:17 Now if only the node package manager (npm) would get its stuff together and run on windows, so we could pull down express/etc and do real work. Ray O'Neill August 29, 2011 5:58 Now, I nearly failed math in school, but wouldn't (nothing * infinity) == nothing? ;) stevesyfuhs.myopenid.com August 29, 2011 7:22 @Keith iisnode is not an ms project. Liam McLennan August 29, 2011 12:28 Anyone get this running on a 64 bit system? Mike August 29, 2011 12:53 Very cool - I did have a brief look at iisnode and really didn't get time to go into it.. David Sheardown August 29, 2011 13:56 I am thinking this would be perfect for web sockets using Socket.IO. Rooney August 29, 2011 14:00 Rooney - via JSON over HTTP, sure! Scott Hanselman August 29, 2011 15:24 I love node, I also love Visual Studio. Ewoud van den Boom August 29, 2011 18:30 FYI: Here is a (sadly abandoned) MSSQL driver for node.js: https://github.com/orenmazor/node-tds John Dyer August 29, 2011 18:53 @Liam: As far as I know, Issac has said NPM will definitely support Windows, but he's waiting until the v0.5.x branch is more stable. I assume NPM will support Windows by the time v0.6 is released. xtian August 30, 2011 0:39 @ScottH, thank you for this write-up. Just great to see work on this front, even if it's early work. Gaëtan Voyer-Perrault August 30, 2011 1:00 Mike - Weird, I'm running it on my 64bit system but I used the 64 bit build. Node.exe is 32 but though. I'll double check. Scott Hanselman August 30, 2011 2:17 Scott - Mike August 30, 2011 2:24 Mike - I'm running integrated pipeline. Scott Hanselman August 30, 2011 2:28 I wonder about the role of the App pool here. It should only fire up node.exe, which is a separate process - not a w3wp one (is it?) Ken Egozi August 30, 2011 3:41 Can I ask a dumb question? Marcel Bennett August 30, 2011 4:50 Scott - Mike August 30, 2011 10:23 When you are a c# developer. I'd understand the desire to have a c# implementation of node.. juul August 30, 2011 12:48 @juul Andrew Corkery August 31, 2011 0:32 I've set everything up including setting the AppPool to run as LocalSystem and setting the node applicaiton to run in that app pool. When I browse to any of the .js files that should execute I instead get the download box. What am I doing wrong? Brian August 31, 2011 0:41 Another asynchronous .NET option is the Reactive Extensions: Jed August 31, 2011 6:48 Scott - Mark Struck August 31, 2011 6:55
I think this is the most important basic difference between Node.js and other popular web servers like Apache or IIS. Couple this with the fact that it's so light-weight and supports JavaScript, and it's rapidly becoming one of the most exciting things I've come across in years. I really wonder how it does in terms of security. My guess is you can build some pretty dangerous apps if you're not careful. Dan Tohatan August 31, 2011 7:58 Brian Mike August 31, 2011 18:15 Hi Scott, Thanks for the detailed & brief rundown on what Node is and why to consider using it. I've been wanting to research it, but never had time. Steel Palisade August 31, 2011 19:05 Mike, Brian August 31, 2011 19:06 Also, I'm running Win 7 64 bit. I had to install the AMD 64 version of iisnode. Brian August 31, 2011 21:35 sssh stop talking about this secret :) it is awsome. man I wish MS would sell IIS to run on different platforms :) Craig September 01, 2011 3:32 I'm running into the same issues Mike was having. Any tips would be appreciated: Randy September 01, 2011 4:47 If you run into a 503 status code with IIS reporting error code 0x5 (ERROR_ACCESS_DENIED), make sure the identity of the application pool running the site that hosts your node.js application has read & execute rights to node.exe on disk. If you are using the default IIS configuration (DefaultAppPool running under ApplicationPoolIdentity), you can set appropriate ACLs on the node.exe by running: Tomasz Janczuk September 01, 2011 9:46 Randy - you might be seeing the same issue I was. I had to install the VS 2010 x64 redist binaries: David Shoots September 01, 2011 21:37 Thanks guys. Randy September 03, 2011 9:55 This is really cool. I've been running a vm to do my NodeJs development but this will really help out. Kneale Alpers September 03, 2011 16:31 Thank you Scott for this introduction to node.js and sharing your first steps using iisnode. As you write "Node isn't always the solution, but it does solve some important problems". It's good to have this choice on the Windows platform. What's coming next: package management with "npm" or VS.NET-integration? I'm curious about it. MARTINSFELD September 05, 2011 5:36 I was hoping to see CoffeeScript working with iisnode, but as I haven't seen anyone even mention a CoffeeScript-on-iisnode implementation it seems it's going to need its own implementation on top of it. CoffeeScript has a Javascript-based compiler so CoffeeScript will run anywhere, but real CoffeeScript development involves working with .coffee files and a runtime that knows to automatically pre-load the CoffeeScript compiler and load these .coffee files straight in. Doable, perhaps even easily doable, but I doubt it's doable without directly manipulating the iisnode codebase itself to support pre-loaders and compilers to be declared in the web.config'uration. Does anyone know otherwise? stimpy77 September 05, 2011 8:21 Gorgeous! 柱元 香 September 17, 2011 13:08 Scott, regarding your comment on the SYSTEM permissions, why don't you use process monitor to determine exactly what username is being used, which folders and grant accordingly. I realize the common developer would say, who needs permissions. :) I'm from the admin side and try to practice only granting what you need. I realize a development environment is one thing and production is another, I see too many posts where someone is a developer first and then expected to know just enough to setup a server. That might be an over-generalization. :) Anywho, thanks for the good article, I have a better understanding now. Steve Schofield October 14, 2011 20:04 hi, I can use async+await as a standard .NET way and have the same results like you've got with node? Bohdan Cherchyk December 14, 2011 20:00 Thanks for the blog. binjiezhao January 08, 2012 2:25 iisnode - Installed it. Installer put it in c:\Program Files\iisnode, not inetpub. Also, there is no install.bat. There's a setupsamples.bat, which I ran. There's also an etw.bat. Not sure what that's for. Kevin Dietz January 21, 2012 19:52 Hi scott is there any possibility that node.js will take over ASP.NET and WCF? Amit January 23, 2012 11:19 What I'm not getting is how is this an improvement over JScript? ASP classic has provision for javascript in the form of JScript and there is also JScript.NET. Both of these give you access to ADO for MSSQL. As far as ASP classic goes, as long as your webserver has a recent version of IE installed you also have access to everything in IE's client-side javascript including regular expressions as in: Bài Viết Liên QuanCó thể bạn quan tâmXem NhiềuChúng tôiTrợ giúp |