I'm really enthused about the sharing of network ports between forked processes using the new cluster framework, but what I can't figure out from the documentation is: Which processes gets which requests? How is the load actually balanced?
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: 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 post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
The master accepts the connection, then hands it off to one of the
workers. The load distribution is operating system dependent but
usually round-robin.
Can the master pass any context data together with the connection ?
For example, let's say, some session data ?
> The load distribution is operating system dependent but
> usually round-robin.
I don't get why, if it's the master who accepts the connection, why is the distribution operating system dependent ?
Thanks in advance,
--
Jorge.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: 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 post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
Sorry, I explained it wrong: s/master accepts the connection/creates
the bound socket/
In a nutshell:
1) the master creates and binds the socket, then passes it to the
workers (using cmsg file descriptor passing on Unices)
2) the workers (and the master too) listen on the socket
3) when a connection arrives, the operating system wakes up one of the listeners
Yes, but consider that a feature. If you want horizontal scalable web
apps, session affinity is one of the first things to go.
Throwing sessions to redis or memcached did solve the problem, but I don't wanna import them to some "small" applications, it's just too heavy weighted.
If you want to hold session data in memory, with no persistence, you can just use another node process. Or, you could use worker.send to broadcast session changes to all the workers and keep a copy of the data in each process. If your data is less than a couple MB it would be cheaper than starting another node process. Or maybe you don't actually need a cluster for some of these smaller projects?Throwing sessions to redis or memcached did solve the problem, but I don't wanna import them to some "small" applications, it's just too heavy weighted.
> I'm really surprised anyone is doing server-side sessions these days.
...I was not aware there were viable alternatives. Coming from the PHP world, it's pretty damn ubiquitous to store things in $_SESSION, and the node tutorials I've seen so far do similarly.