Node.js Versus Apache2: Bare Bones Test Node.js Versus Apache2: Bare Bones Test

I've written a few recent articles on Node.js, mostly to familiarize myself with the effort involved in creating basic applications with it.† I have yet to use it in production, mostly because Iím just not sure how ready I am to use it on a large projectÖ

I have been quite curious with performance compared to the standard tools that†I've†used forever and ever.† In the following article, Iím going to do some basic comparisons between Node and Apache2 performance.

†To begin, I need to create two extremely simple websites, one for Node.js and one to be used for Apache.

Letís begin with the Apache website; it will be a basic HTML page with Hello World outputted on screen:

<!DOCTYPE html>
<html lang="en">
<title>Hello World</title>
<h1>Hello World</h1>

Thatís nice and simple.† I proceeded to create a new virtual host and placed this index.html in its webroot.

Next, I will create a basic Node.js website.† In this example, I will use both Express and the Jade templating system.† This need to be installed if they are not already, so I will create a packages.json file:

"name": "my-test-project",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "~3.0.0",
"jade": ">= 0.0.1"

Now in a command prompt inside the folder where this file is present, I can run npm install and it will download and install both the Express and Jade packages.

Next up is a basic app.js file with one route for /:

var express = require('express');
var app = express();
app.set('view engine', 'jade');
app.get('/', function(req, res){
res.render("index.jade", {layout:false});

This creates a new Express server, defines the view engine as Jade and displays the index.jade file for the / route.† Here is a basic views/index.jade file:

!!! 5
title Hello World
h1 Hello World

This will also output Hello World to screen just like the basic index.html file created earlier.† Now inside a command prompt I can start the application by typing node app.js.

Itís now time to compare Apples-to-Apples using my basic speed tester.

The results are astonishing!

First up I will run the speed tester on my Apache application.† In 10 seconds, the speed tester was able to load my Apache website 300 times.

And finally running the speed tester on my Node application, in 10 seconds the speed tester was able to load my Node application an incredible 6500+ times!


Iím incredibly astonished at the difference between the two results.† Itís important to note that Iím simply running this on my laptop running Windows 7.† There might be better or worse results running this on a production server running a different Operating System.† None-the-less, in this case the results speak for themselves.† Node out performed Apache by 21 requests to every 1 request!

Published on Dec 3, 2012

Tags: Optimization | speed comparison | Node js Tutorial | Theory | JavaScript | apache

Related Posts

Did you enjoy this article? If you did here are some more articles that I thought you will enjoy as they are very similar to the article that you just finished reading.


Learn how to code in HTML, CSS, JavaScript, Python, Ruby, PHP, Java, C#, SQL, and more.

No matter the programming language you're looking to learn, I've hopefully compiled an incredible set of tutorials for you to learn; whether you are beginner or an expert, there is something for everyone to learn. Each topic I go in-depth and provide many examples throughout. I can't wait for you to dig in and improve your skillset with any of the tutorials below.