Wednesday, September 7, 2011

Node.js vs PHP response time metrics

I recently did a small Hello World Time Metric Test to see response time on Node.js and PHP and plotted the graph to see the performance difference between the two. PHP was hosted on a LAMP stack while node.js was downloaded via apt-get install. Instructions can be found on .

The node.js script was simple hello world script:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "");
console.log('Server running at');

While the PHP script used was:

echo "Hello World";


The tester script was:

while($j<100) {


while($i<10000) {

print(' ');

Any guesses on which performed better. Node.js was a clear winner over php. Although this script did'nt utilized any event based advantages of node.
In the above chart Column A is Node.js while Column B is PHP.