PHP vs. Node.js: The REAL statistics
prahladyeri.com
prahladyeri.com
I doubt that. PHP will stay because of Path dependency, most webhosters provide PHP, because software is written in PHP. Software is written in PHP, because it is most widely supported. I like node better, though.
While I enjoyed the benchmark test, I believe the conclusion that this is going to be de-facto as a result of it's high performance is a bit premature. There are so many factors (both right and wrong) that contribute to the widespread adoption to a language/framework/technology, performance often being less important than you'd at first think.
EDIT: I'm not suggestion node will or will not be a de-facto. I'm suggesting that the factors contributing to a languages widespread adoption are varied and complex.
Yup, thats true, and being performance oriented isn't the only selling-point for node.js. The fact that all node apps are single-threaded (and thus conserve cpu capacity), combined with the functional-programming approach of javascript (which makes things like async I/O easier, don't hurt either.
JavaScript indeed has functional programming features. See: https://en.wikipedia.org/wiki/Javascript
(For anyone wondering about performance, it served pages about twice as fast on average as PHP-FPM 5.4.4 on the same box, and with drastically lower memory usage in all cases. Didn't delve too much deeper into that, though, since the page not rendering correctly was a showstopper.)
The test isn't completely invalid, but there is a lot more going on than what is described. It's a bit misleading to say that the server blocks waiting for file_get_contents. Actually, only the thread running the PHP script blocks. Other threads/processes can run. This experiment isn't quite a test of blocking versus non-blocking I/O. It's more a comparison of a heavy apache + PHP stack versus a lightweight, single-function node.js http server, which also probably benefits from non-blocking I/O. But non-blocking I/O is only one of many things that make the node script faster.
Yup. But imagine a situation that suddenly around 10000 requests have arrived at your server and sitting on the queue. Now that "one php thread" suddenly becomes a life-saver.
It would be interesting to see a breakdown of what makes the apache+PHP solution so slow. apache probably eats a lot of time by itself.
Are you using an opcode cache for PHP, like APC? The PHP script is being executed repeatedly, possibly being read, parsed and translated into bytecode each iteration. The Javascript gets compiled once into native code by v8 and just loops.
As for apache eating time, nginx might run a bit faster than apache, but without a proper async I/O model built into the language itself (such as functional javascript), it would still be a band-aid solution.
Also I didn’t need any test because since the first time I ran node.js it was instant fast, not like php, ruby or python.
The real question for most projects should be which is faster to develop with and has a better ecosystem.
"Hey guys, I was wondering if node really is faster than PHP, so I checked. It is! End of story."
For many of the people using these tools, the benchmarks don't matter. Most people do okay with their Wordpress or Drupal sites. Application developers understand that the limitations of attempting to use a CMS as a platform and they have wide choices (not just PHP or Node.)
It takes about a second. I expected it to be faster than node and php, but it being this much faster makes me think I got something wrong. The files generated aren't all the same.
Personally i prefer http://www.techempower.com/benchmarks/ reply if anyone knows something better than that one