3 ms·
Why do you believe that PHP would cause issues that Nodejs would not?
by Nican 4y ago
Why do you believe that PHP would cause issues that Nodejs would not?
- paulryanrogers 4y agoPHP is usually run multi-process, so may have more parallel activity than a single Node instance running single threaded
- calt 4y agoYour mental model of concurrency is not correct. Node.js uses non-blocking IO to achieve massive amounts of concurrency on a single thread, while one-thread-per-request models such as PHP rely on OS threading to do the exact same thing. If anything, the node.js model is often capable of more concurrency because of the inefficiencies involved in OS threading and context switching. EDIT: of course, event driven PHP exist. I don't know much about the current state of it.
- Nican 4y agoThe answer here is non-trivial. I have since long stopped developing with PHP, but PHP has several run modes (And multiple runtimes like HHVM), that may bring different performance and concurrency characteristics. Last I remember, PHP still runs all inside of a single process, so it still all share the same memory space, and it no longer has the overhead of starting a new process with every request. The piece of engineering that made node.js so fast back in the day was Libuv, which allowed for non-blocking IO, greatly reducing the number of system calls/context switches. But I am also going to guess that PHP developers have since caught on to the performance optimizations of non-blocking IO, and integrated the improvements into the runtime. Doing a quick search for "php vs nodejs benchmark" on Google [1], it seems like the performance of Nodejs is comparable to that of HHVM. So as usual, use the right tool for the job. This is more of a problem of using your tooling correctly, more than choosing the correct language. [1] https://yuiltripathee.medium.com/node-js-vs-php-comparison-get-the-job-done-purpose-d3d63351ea8a https://yuiltripathee.medium.com/node-js-vs-php-comparison-g...
- onlypositive 4y agoI used PHP but probably should have specified modphp or phpfpm.