Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I did a rudimentary performance test between nodejs and IIS. IIS is about 2.5 times faster than nodejs when dishing out "hello, world!". code below.</p> <p>my hardware: Dell Latitude E6510, Core i5 (dual core), 8 GB RAM, Windows 7 Enterprise 64 bit OS</p> <p>node server</p> <pre><code>runs at http://localhost:9090/ /// &lt;reference path="node-vsdoc.js" /&gt; var http = require("http"); http.createServer(function (request, response) { response.writeHead(200, { "Content-Type": "text/html" }); response.write("&lt;p&gt;hello, world!&lt;/p&gt;"); response.end(); }).listen(9090); </code></pre> <p>default.htm</p> <pre><code>hosted by iis at http://localhost/test/ &lt;p&gt;hello, world!&lt;/p&gt; </code></pre> <p>my own benchmark program using task parallel library:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; namespace HttpBench { class Program { private int TotalCount = 100000; private int ConcurrentThreads = 1000; private int failedCount; private int totalBytes; private int totalTime; private int completedCount; private static object lockObj = new object(); /// &lt;summary&gt; /// main entry point /// &lt;/summary&gt; static void Main(string[] args) { Program p = new Program(); p.Run(args); } /// &lt;summary&gt; /// actual execution /// &lt;/summary&gt; private void Run(string[] args) { // check command line if (args.Length == 0) { this.PrintUsage(); return; } if (args[0] == "/?" || args[0] == "/h") { this.PrintUsage(); return; } // use parallel library, download data ParallelOptions options = new ParallelOptions(); options.MaxDegreeOfParallelism = this.ConcurrentThreads; int start = Environment.TickCount; Parallel.For(0, this.TotalCount, options, i =&gt; { this.DownloadUrl(i, args[0]); } ); int end = Environment.TickCount; // print results this.Print("Total requests sent: {0}", true, this.TotalCount); this.Print("Concurrent threads: {0}", true, this.ConcurrentThreads); this.Print("Total completed requests: {0}", true, this.completedCount); this.Print("Failed requests: {0}", true, this.failedCount); this.Print("Sum total of thread times (seconds): {0}", true, this.totalTime / 1000); this.Print("Total time taken by this program (seconds): {0}", true, (end - start) / 1000); this.Print("Total bytes: {0}", true, this.totalBytes); } /// &lt;summary&gt; /// download data from the given url /// &lt;/summary&gt; private void DownloadUrl(int index, string url) { using (WebClient client = new WebClient()) { try { int start = Environment.TickCount; byte[] data = client.DownloadData(url); int end = Environment.TickCount; lock (lockObj) { this.totalTime = this.totalTime + (end - start); if (data != null) { this.totalBytes = this.totalBytes + data.Length; } } } catch { lock (lockObj) { this.failedCount++; } } lock (lockObj) { this.completedCount++; if (this.completedCount % 10000 == 0) { this.Print("Completed {0} requests.", true, this.completedCount); } } } } /// &lt;summary&gt; /// print usage of this program /// &lt;/summary&gt; private void PrintUsage() { this.Print("usage: httpbench [options] &lt;url&gt;"); } /// &lt;summary&gt; /// print exception message to console /// &lt;/summary&gt; private void PrintError(string msg, Exception ex = null, params object[] args) { StringBuilder sb = new System.Text.StringBuilder(); sb.Append("Error: "); sb.AppendFormat(msg, args); if (ex != null) { sb.Append("Exception: "); sb.Append(ex.Message); } this.Print(sb.ToString()); } /// &lt;summary&gt; /// print to console /// &lt;/summary&gt; private void Print(string msg, bool isLine = true, params object[] args) { if (isLine) { Console.WriteLine(msg, args); } else { Console.Write(msg, args); } } } } </code></pre> <p>and results:</p> <pre><code>IIS: httpbench.exe http://localhost/test Completed 10000 requests. Completed 20000 requests. Completed 30000 requests. Completed 40000 requests. Completed 50000 requests. Completed 60000 requests. Completed 70000 requests. Completed 80000 requests. Completed 90000 requests. Completed 100000 requests. Total requests sent: 100000 Concurrent threads: 1000 Total completed requests: 100000 Failed requests: 0 Sum total of thread times (seconds): 97 Total time taken by this program (seconds): 16 Total bytes: 2000000 nodejs: httpbench.exe http://localhost:9090/ Completed 10000 requests. Completed 20000 requests. Completed 30000 requests. Completed 40000 requests. Completed 50000 requests. Completed 60000 requests. Completed 70000 requests. Completed 80000 requests. Completed 90000 requests. Completed 100000 requests. Total requests sent: 100000 Concurrent threads: 1000 Total completed requests: 100000 Failed requests: 0 Sum total of thread times (seconds): 234 Total time taken by this program (seconds): 27 Total bytes: 2000000 </code></pre> <p>conclusion: IIS is faster than nodejs by about 2.5 times (on Windows). This is a very rudimentary test, and by no means conclusive. But I believe this is a good starting point. Nodejs is probably faster on other web servers, on other platforms, but on Windows IIS is the winner. Developers looking to convert their ASP.NET MVC to nodejs should pause and think twice before proceeding.</p> <p>Updated (5/17/2012) Tomcat (on windows) seems to beat IIS hands down, about 3 times faster than IIS in dishing out static html.</p> <p>tomcat</p> <pre><code>index.html at http://localhost:8080/test/ &lt;p&gt;hello, world!&lt;/p&gt; </code></pre> <p>tomcat results</p> <pre><code>httpbench.exe http://localhost:8080/test/ Completed 10000 requests. Completed 20000 requests. Completed 30000 requests. Completed 40000 requests. Completed 50000 requests. Completed 60000 requests. Completed 70000 requests. Completed 80000 requests. Completed 90000 requests. Completed 100000 requests. Total requests sent: 100000 Concurrent threads: 1000 Total completed requests: 100000 Failed requests: 0 Sum total of thread times (seconds): 31 Total time taken by this program (seconds): 5 Total bytes: 2000000 </code></pre> <p>updated conclusion: i ran the benchmark program multiple times. Tomcat appears to be the fastest server in dishing out STATIC HTML, ON WINDOWS.</p> <p>Updated (5/18/2012) Previously I had 100,000 total requests with 10,000 concurrent requests. I increased it to 1,000,000 total requess and 100,000 concurrent requests. IIS comes out as the screaming winner, with Nodejs fairing the worst. I have tabularized the results below:</p> <p><img src="https://i.stack.imgur.com/9YDGA.gif" alt="NodeJS vs IIS vs Tomcat serving STATIC HTML on WINDOWS">.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload