Use node.js or PHP with WebSockets?

5

Using WebSockets for my project, in the end was an extensive project with thousands of lines of code in PHP.

As soon as I finished typing everything and "finished" they told me that running WebSockets with PHP is unfeasible for large-scale users because it is synchronous and executes everything again for each request.

I was recommended node.js as an alternative due to the low overhead and be asynchronous.

But at the same time I think that if the execution architecture inside the server is adequate trying to the maximum do not have many expenses the use of one language or another for the same purpose ends up getting them for them.

My inquiries are specifically:

  • Is there any proportion to node.js and PHP that demonstrates the how many% would it be more efficient, or something like that?

  • Is there an alternative so I do not have to quit PHP? Even if I change the structures of my project

My situation is frustrating, and as today's projects can fill up with users or not, I do not know where to run.

    
asked by anonymous 06.10.2015 / 04:47

1 answer

3

PHP v NODE.js - The question that PHP loads everything again varies from one factor, if PHP runs on Apache as a process, creating each request a new instance, or if it runs on FastCGI, which we can limit the number of threads associated with the single process, so the execution is asynchronous, the execution of this mode is generally applied in Lighttpd and Nginx, although it can be applied in Apache as well.

Using FastCGI / PHP will basically achieve the same result, although Node.js is easier for creating applications that use Websocket. As you already have the application done, I recommend keeping PHP and using FastCGI.

    
29.10.2015 / 12:43