I’m trying to figure out whether or not this would be a decent usecase for node.js child processes:
I have a multiple player game where people are engaged into 1v1 matches. Should I use a child process for each match?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not really needed. Since node is event based and a single process would be able to handle thousands of such player pairs. You would be creating “rooms”/”groups”/”channels” for each such pair, assuming that you are using now.js. The nomenclature may vary according to the library you use, but overall approach would be same – to assign all the players who are going to play against each other in same “channel”. If you are actually using a child process for each such player pair you are actually killing the purpose with which node.js is built.
On the other hand real world use case of spawning a child process is implemented in forever.js(as well as cluster.js). Here a child process ( also know as worker ) is spawned by master process. The worker process do the actual work, say processing a HTTP request, while master process is to only monitor the worker process and spawns new worker process if existing one dies ( due to various reasons ). Child process are also used for calling out non-nodejs applications.