php vs nodejs performance on websockets server

5
What I take for granted today is that nodejs is best suited to work with a constant pool of sockets (websockets in this case) because by being single-threaded each new connection generates an extra minimal memory consumption (a few hundred KBs), for php every new connection would generate a new process that would consume a few extra megabytes.

Am I right or wrong on this idea? regardless of the response, because one language would be preferable to another in the implementation of a websockets server?

    
asked by anonymous 15.02.2016 / 00:25

1 answer

3

Am I right or wrong on this idea?

You're partially right, or partially wrong.

NodeJS works with a single process, which executes a loop de eventos . Each message exchanged, connection that opens, connection that closes is evento . So, in theory, it's easier to develop websocket applications with NodeJs.

With PHP you can try doing the same by creating a long running process that communicates with your PHP application. There are already some libraries to help you with this architecture:

However, if you want something much more like NodeJS, there is the extension PHPReact .

Why would one language be preferable to another in the implementation of a websockets server?

First comes the taste. Use the language you like, even if it does not perform as well as others.

Second comes the job market. If you create a project that turns out to be a product or a company, use a language that is easier to find people to work with.

Lastly comes cost. In the future, if your application has millions of hits and you want to save money, it's worth changing the language, even if that language is not your favorite or not very popular among developers. Netflix migrated the application that generates the Java UI to NodeJS and thus reduced server spending by 70%. NodeJs In Flames

    
03.03.2016 / 17:25