80

Possible Duplicate:
Why and When to use node js?

Can someone tell me why all this fuss about node.js ? Is a regular web site (lets say a blog) written in node.js faster compared to same written in some php framework? I know that a web server written in node.js will be faster than apache but how about a real web application that doesn't create threads or something like that?

Community
  • 1
  • 1
overthetop
  • 1,664
  • 2
  • 15
  • 25

1 Answers1

55

Edited:

There are 2 main advantages:

  1. Speed! (Performance)
  2. Node.js is event-driven and non-blocking and very good at handling concurrent requests.

Here is a link to a benchmarking test for node.js against PHP on Apache.

Community
  • 1
  • 1
Robin Maben
  • 22,194
  • 16
  • 64
  • 99
  • 3
    yes i know that node.js web server is faster than apache :) so it is only the web server advantage? – overthetop Apr 11 '11 at 14:04
  • Yes, that advantage is too cool to resist but I must also mention there's no large community support yet. So you'd have to be very daring to go with node.JS for your next project. – Robin Maben Apr 11 '11 at 14:13
  • 22
    I'd say the main advantage is memory usage. If you do long-polling stuff node.js shines since it doesn't require a 100 MB Apache + PHP instance to handle each request. So if you do anything where you have many connections open at the same time - for long periods of time - go with node.js. Usually they coexist well. use node.js for updating a chat panel or similar, not to render your pages. – oldwizard Apr 14 '11 at 09:24
  • 5
    You forgot to mention one of the most important features: it's non-blocking! – Alix Axel May 18 '11 at 19:42
  • 19
    A port of WordPress to Node.js would be awesome. hah – trusktr Apr 23 '12 at 10:44
  • 3
    @trusktr http://tryghost.org/ – Nico Burns May 05 '13 at 00:57
  • @NicoBurns That looks freackin' awesome. – trusktr May 06 '13 at 04:20
  • If I make a new freelance site for someone, I'll have to try Ghost. – trusktr May 06 '13 at 04:21
  • last time i checked node.js can't use multi core servers.. :-) so why is that good... since php/apache can use a multi core and it's performance will be better.. :-) – Bogdan Aug 25 '13 at 19:16
  • 1
    @Bogdan Check again- http://stackoverflow.com/questions/2387724/node-js-on-multi-core-machines – FredTheWebGuy Sep 04 '13 at 07:48
  • my bad :-) seems that i'm not good with news – Bogdan Sep 05 '13 at 21:43
  • 2
    NodeJS is slower then PHP 5.5.5 + React + phpQuery see http://philsturgeon.co.uk/blog/2013/11/benchmarking-codswallop-nodejs-v-php – barbushin Nov 25 '13 at 05:01
  • As SeniorDev eluded to, PHP can support non-blocking if you want such a thing. http://reactphp.org/ . I wouldn't say NodeJS is necessarily slower though. As Phil has pointed out in updates, increasing the max connections of NodeJS gets the two setups in his test neck and neck. – Gremio Dec 04 '13 at 19:40
  • @RobinMaben From my perpective memory leaks would be the biggest disadvantage with Node. Running a web app on a V8 core for days; no wonder. – Rolf Sep 23 '14 at 13:11
  • 1
    How does node JS compare to Php on Apache/nginx when it comes to I/O operation like downloading or streaming large video files from object storage sever like S3 buckets ? – Andy Jul 05 '16 at 21:59
  • Normally, you write code in in Java,php,python,c# in "blocking" traditional way, that means when a tasking is executing, other tasks must wait for it to completed (in a queue) In Nodejs, the basic concept is the "non-blocking" way, that means when a tasking is executing, other tasks dont need to wait for it to completed. – channasmcs Oct 11 '16 at 07:52
  • What about running php on Nginx ? – Maaz Rehman Mar 27 '17 at 09:38
  • how about php7? – AVI Aug 12 '17 at 09:40
  • 2
    What about in >= 2020 , PHP version 7+ uses less memory and became super fast and secured ? – Abhishek Kamal Jul 05 '20 at 15:05