Let Nodejs run on IIS

Source: Internet
Author: User

The benefits of node running on IIS:

Tomasz's answer is the best I've ever seen:

The advantage of using the Iisnode module to host a node. js application in IIS instead of a self-hosted node.exe process is:

· process Management. the Iisnode model focuses on the long-term management of the Node.exe process and can improve overall reliability more succinctly. You don't need to implement the underlying tools for running, stopping, or displaying processes.

· Scalability on multi-core servers. since node.exe is a single-threaded process, it can only be applied to single-core CPUs. While the iisnode module allows multiple node.exe processes to be created per application , and based on the HTTP The flow adjustment makes it load balanced. To maximize server CPU performance without the need for additional base code.

· Automatic Updates. The Iisnode module ensures that the node. JS application is kept up to date (e.g., updated when the script file changes),Node.exe The process gets looped. An older version of the app can correctly complete the in-progress request execution, and all new requests are dispatched to the latest version of the app.

· through HTTP access logs. the Iisnode module provides access to the output in the Node.exe process over HTTP. (for example, the output generated by the Console.log call). This feature is key to helping you debug your node. js application on a remote server .

· connected to other content types. The Iisnode module is compatible with IIS , allowing a single web Pages can cover many content types. For example, a single page can contain a node. js Application, Statistical HTML,JavaScript Files,PHP applications, and ASP . This allows the user to choose the most appropriate tool, without having an application complete the migration.

· just change the few parts node. js application code. The Iisnode module supports minimal changes to host an existing HTTP node. js application. You only need to change the address listed by the HTTP server to Iisnode via the process.env.PORT environment variable the address provided is available.

converged management experience. The Issnode module fully integrates the IIS configuration system and uses the same tools and mechanisms, similar to IIS Configuration and maintenance of other components.

in addition to facilitating Iisnode A specific point in the module, IIS hosted in node. js The app also allows developers to IIS features, including:

      • port sharing (via the multiple ports host multiple HTTP application)
      • Security ( HTTPS , authentication and authorization)
      • URL rewrite
      • Compression
      • Cache
      • Log

are very convincing, but in my opinion, the most interesting is the number of integration. The Iisnode module is a reasonable IIS module, just like ASP. This means you can see a variety of content on a single website. As mentioned above:

For example, a single page station can contain a node. js Application, Statistics HTML , JavaScript files, PHP Applications and ASP application.

Some of my colleagues heard me say that you can use ASP. NET WebForms and ASP. NET MVC in the same apppool like "half-breed", you get mad. Dear readers, everyone is unaware of the power and flexibility of IIS. When you insert something new like node, but still do it in the old way, it still continues all the benefits that it contains.

Well, you talked me into it, so how do I run node. js on Windows?

I assume you're running a IIS7.

· To download Node.exe, put it in C:\node

· To download Iisnode.

· Unzip the Iisnode compression pack and unzip it to \inetpub\iisnode

· (Just my advice, not necessarily the best position)

· Run Install.bat as an administrator on the command line.

Install.bat will be:

· Unregister the existing "Iisnode" global module from the IIS you installed, if you have already registered.

· Registering Iisnode as a local module in your installation of IIS

· Installing the "Iisnode" module configuration file

· Remove the existing "Iisnode" section from the system.webserver group in ApplicationHost.config

· Add a new "Iisnode" section to the system.webserver group in ApplicationHost.config

· If you have a Iisnode web app, delete it directly

· Add a new Iisnode site for IIS

No guarantee! Be careful, you are walking on the edge. Remember, you just see this article on the blog that you see by chance.

Warning: I don't know the correct apppool and file system permissions, so I gave my local AppPool "system" permission directly. It's bad, it's all my fault. I wrote a question on Iisnode GitHub , and when they have a response I'll find a way to fix it and update it.

I made a new apppool for node, gave it access to the system, and then assigned node site to the new AppPool. That's what your site looks like:

If you click on this module on this page of IIS7, you will see that Iisnode is a local module:

Now, you can click http://localhost/node/helloworld/hello.js and get feedback:

Hello, world!. [HelloWorld Sample]

The content is simple:

1:var http = require (' http ');
3:http.createserver (function (req, res) {
4:res.writehead ($, {' Content-type ': ' Text/plain '});
5:res.end (' Hello, world! [HelloWorld sample] ');
6:}). Listen (Process.env.PORT);

It's great.

Play WCAT (Web Capacity Analysis tool) and node.

Disclaimer: First of all, it's just a play. But to show that it does work, and it runs fast. I didn't do the benchmark, and I didn't say "This works better than any other tool." Remember, they are just getting started and migrating node to Windows,tomasz and his friends just recently. So don't expect too much. What they're doing now is amazing.

I'm really excited. I mean to put a new thing on another new thing, and then just run it once to succeed. After I finished a series of basic work, I wanted to do some simple stress tests to see what people were doing.

First, I installed WCAT, a free web capacity analysis tool developed by the IIS team.

1. WCAT 6.3 x86

2. WCAT 6.3 x64

Warning: This is a command-line-only tool that runs really a bit petty . A bit confusing, setup also took me a bit of time. Here are the steps I installed. is performed from the command prompt for administrator permissions. Note that I do it on the same machine, remember that this is GOM .

1. cscript//H:CScript

2. wcat.wsf–terminate–update–clients localhost

3. Then I built a folder named \nodetests and put the three files in.

Wcat.bat

pushd C:\Users\Scott\Desktop\nodetests
"C:\Program Files\wcat\wcat.wsf"-terminate-run-clients localhost-f settings.ubr-t nodescenario.ubr-s localhost-sing Leip-o C:\Users\Scott\Desktop\nodetests
Pause

NODESCENARIO.UBR ( You can name it )

It's also very simple. It will be called by 4 sample program one by one.

1:scenario
2: {
3:name = "Node_fun";
5:warmup = 30;
6:duration = 90;
7:cooldown = 30;
11:setheader
12: {
13:name = "Connection";
14:value = "Keep-alive";
15:}
16:setheader
17: {
18:name = "Host";
19:value = Server ();
20:}
21:version = HTTP11;
22:statuscode = 200;
23:close = ka;
24:}
26:transaction
27: {
28:id = "Foo";
29:weight = 1000;
30:request
31: {
32:url = "/node/logging/hello.js";
33:}
34:}
35:transaction
36: {
37:id = "Bar";
38:weight = 2000;
39:request
40: {
41:url = "/node/helloworld/hello.js";
42:}
43:}
44:transaction
45: {
46:id = "Baz";
47:weight = 2000;
48:request
49: {
50:url = "/node/defaultdocument/";
51:}
53:transaction
54: {
55:id = "Bat";
56:weight = 2000;
57:request
58: {
59:url = "/node/configuration/hello.js";
60:}
62:}

Settings.ubr

I copied it from another example and removed the comment and made a little modification (modified during the test):

1:server = "Hexpower7";
2:clients = 1;
3:virtualclients = 8;

Now, run to test

Then, I run Wcat.bat as a manager. You will see Node.exe begin to act.

(Remember that they are running on the system, because I am not clear about the right permissions, it is my fault.) I'll figure it out someday. )

This is the console output of the WCAT tool. I can do 10,000 HelloWorld in a second in a row, which will eventually be millions of normal requests and get a response within 90 seconds. That's a lot of HelloWorld.

Remember the rules of Hanselman.

"Do nothing, there is infinite possibility"--I

Of course, these are local operations on a well-configured machine. It's just a HelloWorld (plus some logs), so there's not a lot of test node and IIS, but it's testing the entire system, iis,iisnode and node itself.

Another: ASP. NET IHttpHandler do the same thing on the same machine, and the result is that there are 22,500 requests in a second, so node and Iisnode still have up space, which is good news.

The following are the results of Node/iisnode:

There are a lot of things I can configure on two sites, number of customers, virtual customers, and Iisnode specific settings (all managed in Web. config):

1: <configuration>
2: <system.webServer>
3: 
4: <add name= "Iisnode" path= "hello.js" verb= "*" modules= "Iisnode"/>
5: 
7:nodeprocesscommandline= "%systemdrive%\node\node.exe"
8:maxprocesscountperapplication= "4"
9:maxconcurrentrequestsperprocess= "1024"
10:maxpendingrequestsperapplication= "1024"
11:maxnamedpipeconnectionretry= "3"
13:asynccompletionthreadcount= "4"
14:initialrequestbuffersize= "4096"
15:maxrequestbuffersize= "65536"
16:uncfilechangespollinginterval= "5000"
17:gracefulshutdowntimeout= "60000"
18:loggingenabled= "true"
19:logdirectorynamesuffix= "Logs"
20:maxlogfilesizeinkb= "128"
21:appendtoexistinglog= "false"
/>:
: </system.webServer>
: </configuration>

Let Nodejs run on IIS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.