PHP Vs Node.js, Which is Best?
James William
62

I think you should consider another version of this article where you evaluate PHP7.2 or higher on the latest stable NGINX, using a minimalist PHP framework like Painless MVC (on Github) and then scientifically compare performance.

If you do use Painless, then I recommend commenting out the plugin API in it because you don’t need it for performance testing and it can speed up your code to comment out the call to load the plugin API in the index.php, and also grep the source and comment out any extract() calls that hook that plugin API.

Also use MariaDB instead of MySQL, because the APIs are compatible, and use PDO instead of the deprecated mysql_* and mysqli_* APIs. You can tune MariaDB a little like you can MySQL tuning and get those tips off StackOverflow and ServerFault.

When I do my database connections, I prefer session level connection pooling vs application level connection pooling (via memcached) because it can provide faster performance on slower queries without slowing down your other user sessions on simultaneous access. Then, Maria kicks in and does its own level of connection pooling that you can tweak too.

As for the PHP4 point you made, nobody I know who’s worth their salt in coding even worries about the PHP4 deprecation because most coding is done in PHP5.4 or higher these days. Even with PHP7 out, most coders don’t use the newer features yet and simply do very minor tweaks, if necessary, to get their 5.4 code to work in 7, and use 7.x for its tremendous performance increase. Please also note than PHP does not run fast on code accessed the first time because it has not yet compiled the byte code. So, run your test once to compile everything, throw those stats out, and then re-record your stats when you start over. Now you will see much better performance and can study more real-world PHP7 performance benefits.

Publish your findings and then gather feedback. If it’s warranted, then use that feedback to create a series II of your study so that you can optimize both platforms to their fullest. Do a variety of real-world typical SaaS style business application tasks since Fibonacci and Tower of Hanoi really don’t tell you much for the real world usage.

Check things like connecting to a JSON service API like PostMarkApp, MaxMind, etc. using Curl, CurlMulti, and file_get_contents(). Check things like single table and multi table database reads and writes, and some of those in loops. Check things like file I/O as well. Check things like checking passwords with password_hash() and password_verify(). Also check session and permanent cookie performance, session variable performance, and Memcached application scope variable performance. Check various typical array and string manipulation functions too.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.