Benchmarking Codswallop: Node.js vs. PHP
21–30 of 85 posts
Re: Benchmarking Codswallop: Node.js vs. PHP
#22Long term php guy (I maintained APC for years, slowly given up now), so I've worked a lot with ~2k/3k request-per-second PHP websites. The real trick here is async processing. A lot of the slow bits of PHP code is people not writing async data patterns. If you use synchronous calls in PHP - mc::get or mysql or curl calls, then PHP absolutely sucks in performance. Nodejs automatically trains you around this with a mas…
Re: Benchmarking Codswallop: Node.js vs. PHP
#23I was always under the impression that PHP hate comes from design flaws that make it easy to make mistakes, not from it being necessarily slower.
Re: Benchmarking Codswallop: Node.js vs. PHP
#24Re: Benchmarking Codswallop: Node.js vs. PHP
#25Only a brit would use Codswallop :)
Re: Benchmarking Codswallop: Node.js vs. PHP
#26But the reason for this wasn't that Node/JS is faster than PHP; it was because I was able to write the Node.js app asynchronously, but the PHP version was making hundreds of synchronous requests (this is the gist of the OP).
The issue I have is that Node.js makes asynchronous http calls relatively easy, whereas in PHP, using curl_multi_exec is kludgy, and few libraries support asynchronous requests.
The situation is changing, but the fact remains that asynchronous code is the norm in Node.js, while blocking code is the norm in PHP. This makes it more difficult (as of this writing) to do any non-trivial asynchronous work in PHP.
Re: Benchmarking Codswallop: Node.js vs. PHP
#27Re: Benchmarking Codswallop: Node.js vs. PHP
#281. Takes 1 minute to install on any platform (*nix, windows etc.)
2. A modern Package Manager (NPM) works seamlessly with all platforms.
3. All libraries started from 0 with async baked in from day 0.
4. No need to use any 3rd party JSON serialize/deserialize libs.
5. And above all, its Atwood's law
"any application that can be written in JavaScript, will eventually be written in JavaScript".
http://www.codinghorror.com/blog/2009/08/all-programming-is-...
Re: Benchmarking Codswallop: Node.js vs. PHP
#29Only a brit would use Codswallop :)
I read the entire article in the accent of a West Country farmer. And it still made sense. :)
Re: Benchmarking Codswallop: Node.js vs. PHP
#30Node benchmark is flawed though. Add something like require('http').globalAgent.maxSockets = 64; at the top of node script if you want a fair comparison with async php version. The bottleneck is bandwidth here. Not the runtime. On my laptop, original script from the author took 35 seconds to complete. With maxAgents = 64, it took 10 seconds. Edit: And who is downvoting this? I just provided actual numbers and a way t…
NodeJS v0.10.21 + Cheerio
real 0m47.986s user 0m7.252s sys 0m1.080s
NodeJS v0.10.21 + Cheerio + 64 connections
real 0m14.475s user 0m8.853s sys 0m1.696s
PHP 5.5.5 + ReactPHP + phpQuery
real 0m15.989s user 0m11.125s sys 0m1.668s
Considerably quicker! As I said I was sure NodeJS could go faster, but the point of the article was that PHP itself is not just magically 4 times slower, it is in fact almost identical when you use almost identical approaches. :)