Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offer cluster in production mode #2

Open
shimaore opened this issue Sep 19, 2012 · 6 comments
Open

offer cluster in production mode #2

shimaore opened this issue Sep 19, 2012 · 6 comments

Comments

@shimaore
Copy link
Member

Automatically start multiple workers in production mode, see e.g. the example in http://nodejs.org/api/cluster.html#cluster_event_message which uses os.cpus().length to create one worker per CPU.

Add npm config set production true to documentation.

@Radagaisus
Copy link
Contributor

@shimaore I've pushed a few commits:

  1. There's a script called cluster.coffee for starting in either single or cluster mode.
  2. I've started doing the initializers part of the example app. There's a few default express initializers for all environments in config/initializers/express.coffee.

Please review the commits and close this issue if everything is ok.

I'll continue working on this next weekend.

@shimaore
Copy link
Member Author

shimaore commented Nov 7, 2012

@Radagaisus
Two questions, mostly because I haven't used cluster before:
If I read properly we're starting num_cpus-1 children, correct? (That would be what I expect, just making sure I read the code right).
Don't we need the code in share_express.coffee / share_socket.coffee if disable_io isn't set?

@Radagaisus
Copy link
Contributor

Hi,

  1. No, there are exactly num_cpus forks, so we get 1 master + 4 workers on a 4 core machine.
  2. I don't really understand what's going on there. What's @share? Is this an example of sharing session information between socket.io and express? Does it actually work? All the examples I saw looked very different.
  3. Currently the Express configurations support cluster sessions, but the socket.io don't. I'll add them next weekend.

@shimaore
Copy link
Member Author

shimaore commented Nov 7, 2012

For Socket.io / @share: The model is described in zappajs/zappajs@4d8acdc (there's a picture describing the handshake at the bottom). As far as I know the implementation works.
The main design criteria was that the two services (Express on one hand, Socket.IO on the other hand) might be running on different platforms, and therefor no cookie is shared. On a single server I thought this could also be used in the cluster case.

@Radagaisus
Copy link
Contributor

I'll dig into it.

The updated docs for @share are not up yet on zappajs.com

@scien
Copy link
Member

scien commented Nov 7, 2012

sorry for the delay on zappajs.com. I just hacked it together to pull api/guide/source:client/source:zappa from zappajs.github.com/zappajs so that it always has the most up-to-date docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants