title: Unexpected outcome of node.js vs ASP.NET Core performance test
body: <p>I am doing a quick stress test on two (kinda) hello world projects written in <a href="/questions/tagged/node.js" class="post-tag" title="show questions tagged &#39;node.js&#39;" rel="tag">node.js</a> and <a href="/questions/tagged/asp.net-core" class="post-tag" title="show questions tagged &#39;asp.net-core&#39;" rel="tag">asp.net-core</a>. Both of them are running in production mode and without a logger attached to them. The result is astonishing! ASP.NET core is outperforming node.js app even after doing some extra work whereas the node.js app is just rendering a view.</p>
  <h1>App 1: <code>http://localhost:3000/nodejs</code> <code>node.js</code></h1>
  <p><strong>Using</strong>: node.js, express and vash rendering engine.</p>
  <p><a href="https://i.stack.imgur.com/Wuxhh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Wuxhh.png" alt="nodejs app" /></a></p>
  <p>The code in this endpoint is</p>
  <pre><code>router.get('/', function(req, res, next) {
    var vm = {
      title: 'Express',
      time: new Date()
    }
    res.render('index', vm);
  });
  </code></pre>
  <p>As you can see, it does nothing apart from sending current date via the <code>time</code> variable to the view.</p>
  <h1>App 2: <code>http://localhost:5000/aspnet-core</code> <code>asp.net core</code></h1>
  <p><strong>Using</strong>: ASP.NET Core, default template targeting <code>dnxcore50</code></p>
  <p>However this app does something other than just rendering a page with a date on it. It generates 5 paragraphs of various random texts. This should theoretically make this little bit heavier than the nodejs app.</p>
  <p><a href="https://i.stack.imgur.com/I5TnV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/I5TnV.png" alt="asp.net core app" /></a></p>
  <p>Here is the action method that render this page</p>
  <pre><code>[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
  [Route(&quot;aspnet-core&quot;)]
  public IActionResult Index()
  {
      var sb = new StringBuilder(1024);
      GenerateParagraphs(5, sb);
  
      ViewData[&quot;Message&quot;] = sb.ToString();
      return View();
  }
  </code></pre>
  <h1>Stress test result</h1>
  <h2>Node.js App stress test result</h2>
  <p>Update: <a href="https://stackoverflow.com/questions/43920942/unexpected-outcome-of-node-js-vs-asp-net-core-performance-test?noredirect=1#comment75157955_43920942">Following suggestion by Gorgi Kosev</a></p>
  <p>Using <code>npm install -g recluster-cli &amp;&amp; NODE_ENV=production recluster-cli app.js 8</code></p>
  <p><a href="https://i.stack.imgur.com/zTLuH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zTLuH.png" alt="nodejs test 2" /></a></p>
  <h2>ASP.NET Core App stress test result</h2>
  <p><a href="https://i.stack.imgur.com/fajFZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fajFZ.png" alt="asp.net core stress test result" /></a></p>
  <p>Can't believe my eyes! It can't be true that in this basic test asp.net core is way faster than nodejs. Off course this is not the only metric used to measure performance between these two web technologies, but I am wondering <strong>what am I doing wrong in the node.js side?</strong>.</p>
  <p>Being a professional asp.net developer and wishing to adapt node.js in personal projects, this is kind of putting me off - as I'm a little paranoid about performance. I thought node.js is faster than asp.net core (in general - as seen in various other benchmarks) I just want to prove it to myself (to encourage myself in adapting node.js).</p>
  <p>Please reply in comment if you want me to include more code snippets.</p>
  <p><strong>Update:</strong>
  <strong>Time distribution of .NET Core app</strong></p>
  <p><a href="https://i.stack.imgur.com/tlSDf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tlSDf.png" alt="aspnetcore app time distribution" /></a></p>
  <p><strong>Server response</strong></p>
  <pre><code>HTTP/1.1 200 OK
  Cache-Control: no-store,no-cache
  Date: Fri, 12 May 2017 07:46:56 GMT
  Pragma: no-cache
  Transfer-Encoding: chunked
  Content-Type: text/html; charset=utf-8
  Server: Kestrel
  </code></pre>