What are the advantages of using Node.js vs PHP

77,717

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.

Share:
77,717

Related videos on Youtube

overthetop
Author by

overthetop

:]]

Updated on July 05, 2022

Comments

  • overthetop
    overthetop almost 2 years

    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?

    • Rahul Chordiya
      Rahul Chordiya about 13 years
      why are you comparing client side script with server side script???
    • akamike
      akamike about 13 years
      @Rahul: Node.js is server-side Javascript: nodejs.org
    • ceejayoz
      ceejayoz about 13 years
      @Rahul Node.js is server-side JavaScript.
    • Quentin
      Quentin about 13 years
      @Rahul — JavaScript is "a programming language" not "an exclusively client side programming language". Node.js is not designed to run inside web browsers.
    • overthetop
      overthetop about 13 years
      @rahul node.js is server side framework!
    • Twelve47
      Twelve47 about 13 years
      @Rahul Node.js isn't designed to run in the browser. It isn't just straight js.
    • trusktr
      trusktr about 12 years
      @RahulChordiya Ditto what everyone said. Haha.
  • overthetop
    overthetop about 13 years
    yes i know that node.js web server is faster than apache :) so it is only the web server advantage?
  • Robin Maben
    Robin Maben about 13 years
    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.
  • oldwizard
    oldwizard about 13 years
    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.
  • Alix Axel
    Alix Axel almost 13 years
    You forgot to mention one of the most important features: it's non-blocking!
  • trusktr
    trusktr about 12 years
    A port of WordPress to Node.js would be awesome. hah
  • Nico Burns
    Nico Burns almost 11 years
    @trusktr tryghost.org
  • trusktr
    trusktr almost 11 years
    @NicoBurns That looks freackin' awesome.
  • trusktr
    trusktr almost 11 years
    If I make a new freelance site for someone, I'll have to try Ghost.
  • Bogdan
    Bogdan over 10 years
    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.. :-)
  • FredTheWebGuy
    FredTheWebGuy over 10 years
  • Bogdan
    Bogdan over 10 years
    my bad :-) seems that i'm not good with news
  • barbushin
    barbushin over 10 years
    NodeJS is slower then PHP 5.5.5 + React + phpQuery see philsturgeon.co.uk/blog/2013/11/…
  • Gremio
    Gremio over 10 years
    As SeniorDev eluded to, PHP can support non-blocking if you want such a thing. 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.
  • Rolf
    Rolf over 9 years
    @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.
  • Andy
    Andy almost 8 years
    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 ?
  • channasmcs
    channasmcs over 7 years
    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.
  • Maaz Rehman
    Maaz Rehman about 7 years
    What about running php on Nginx ?
  • AVI
    AVI over 6 years
    how about php7?
  • Abhishek Kamal
    Abhishek Kamal almost 4 years
    What about in >= 2020 , PHP version 7+ uses less memory and became super fast and secured ?