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 http://nodejs.org .

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, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');


While the PHP script used was:


echo "Hello World";

?>

The tester script was:

$j=0;
while($j<100) {
$time1=microtime(true);

$i=0;

while($i<10000) {
   
file_get_contents("http://localhost/hello.php");
$i++;
}



$time2=microtime(true);
print($time2-$time1);
print(' ');
$j++;
}

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.












Comments

  1. nice info bro...thanx's & keep write :D

    dont forget visit http://showgan.blogspot.com/

    ReplyDelete

Post a Comment

Popular posts from this blog

Most expensive product on Amazon India By Category

8 Product Management lessons from the movie 'Gold'