On Jan 19, 2015, at 12:44 AM, Ashish Negi wrote:
> 
> I am making a chat-application. To scale and use all cores, i am creating 
> multiple servers which are listening on same port given by infrastructure for 
> listening. Every information is in memory.
> 
> However, is it possible that lets say.. A and B are chatting each other and 
> have information in process1 and X and Y are chatting and have information in 
> process2.
> 
> My question is :
> 
>       • Do programs compete for each message ? If a new message comes from A, 
> Can it go to process2 which have no information about A or B.
> Or does it depend upon something like if i use simple http messages above 
> problem would happen but if i use web-sockets it would not happen.
> 
> I am using node.js, though i consider it to be a language independent problem.

When you use node's cluster module, the master will listen on the port. If a 
connection is established, node will hand that connection to one of the 
children. Which child it hands the connection to varies. With node 0.11 and 
later, it will be round robin. With node 0.10 and earlier, it is left to the 
discretion of the operating system; often, this means the same (first) worker 
is reused unless it is busy.

To share information between your children, store any important state 
information in a central database, e.g. redis, not in each child's memory.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/6C199557-09DF-4B31-9D36-79B448624103%40ryandesign.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to