DEV Community

Discussion on: Node.js vs PHP

Collapse
 
buphmin profile image
buphmin

So here are a few thoughts of mine using php/node for both web and non web projects.

For this I am assuming php 7+ and node 8+.

So for web I would give node.js the edge, and for an api only node.js for sure. In my experience node simply has better performance in both req/sec and, imo, more importantly response time. A caveat here is if you are doing heavy cpu processing (especially if you can use a php c extension), because php is typically faster in that regard.

So in my testing (not the most scientific method mind you) on my local linux vm using I was able to handle 40x more concurrent requests on node before degrading response time to over 200ms. I have played around with php-pm with a Symfony project and I was impressed with performance, but it would frequently error for no reason I could figure out.

Now I will say the frameworks for php are better (if you like using a framework). I think this has to do with how long php has been around and that people tend to contribute to fewer but very well maintained frameworks in php. Node has a metric crap ton of frameworks and they all seem to have some issues. PHP will also be easier to maintain, though typescript is making node easier.

Overall though if you are looking to make a website that is not internal use only then the performance difference is really hard to ignore. Especially since js is not all that much harder.