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

Could pm2 support the 'ip_hash' feature? #328

Closed
sailxjx opened this issue Feb 28, 2014 · 3 comments
Closed

Could pm2 support the 'ip_hash' feature? #328

sailxjx opened this issue Feb 28, 2014 · 3 comments

Comments

@sailxjx
Copy link
Contributor

sailxjx commented Feb 28, 2014

Sometimes we may store session in memory store or just in local variables (for example, sockjs's MAP variable, and the author seems do not plan to add a redis store),
So I need ensure people visit a single process by every request.

By now my solution is separate applications in multi ports and use nginx ip_hash to proxy request to their node process.

This works well but I wonder if pm2 support this feature in cluster mode, it would be only one port in use, and pm2 will be more powerful and graceful.

Just a proposal.

Cheers.

@AwotwiJ
Copy link

AwotwiJ commented Feb 28, 2014

I doubt that. pm2 is built around node.js cluster module, and it doesn't seem to be supporting this thing. Maybe open a feature request against joyent/node or something.

Can you start your app on different ports and use nginx for this as usual?

@Unitech
Copy link
Owner

Unitech commented Mar 6, 2014

I think that sticky connections will never be implemented in the cluster module. NodeJS apps must be stateless and data must be shared via a database.
The workaround is what @AwotwiJ says, just start your app on different port and do the balancing via Nginx

@Unitech Unitech closed this as completed Mar 6, 2014
@sailxjx
Copy link
Contributor Author

sailxjx commented Mar 6, 2014

Ok, just keep it simple~ 😄

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