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

Make connections sticky to a node instance behind the LB #220

Closed
wants to merge 1 commit into from

Conversation

crzidea
Copy link
Contributor

@crzidea crzidea commented Jan 3, 2014

To support socketio/engine.io#207
Load balancers can use worker id to target a specific node instance behind the LB.

@mokesmokes
Copy link
Contributor

Frankly I don't see great utility in supporting LB schemes that are relevant for one physical machine only. Plus the cluster functionality is labeled "experimental", and actually gets in the way when wanting to scale across machines. How many apps and PAAS are actually using the cluster functionality?

@crzidea
Copy link
Contributor Author

crzidea commented Jan 3, 2014

@mokesmokes

  1. How many apps or PAAS do not support cluster functionality
  2. workerId is just a flag you set to the node instance, not only cluster worker id.
  3. nginx users can easily LB their node instances using the following config:
http {
    upstream channel- {
        server 127.0.0.1:3000;
        server 127.0.0.1:3001;
    }

    upstream channel-1 { server 127.0.0.1:3000; }
    upstream channel-2 { server 127.0.0.1:3001; }
    server {
        listen       8000;
        location / {
            proxy_pass http://channel-$arg_wid;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 120;
        }
    }
}

I understand you are not using nginx or haproxy at the time, but you should know how many users are using them.

@mokesmokes
Copy link
Contributor

This PR still doesn't work as advertised since you're not targeting the initial socket open request (and the following reconnections) - so it's currently an attempt at "sticky connections" rather than connection targeting.

@crzidea
Copy link
Contributor Author

crzidea commented Jan 3, 2014

@mokesmokes Initial socket open request doesn't need to targeting. It should be targeted by load balancer. What you mean about connection targeting?

@crzidea
Copy link
Contributor Author

crzidea commented Jan 3, 2014

@mokesmokes I have updated PR title.

@mokesmokes
Copy link
Contributor

@crzidea take a look at my PR for what I mean. LB is normally a dumb beast that has no clue about the application, and frequently we app devs have no control over it a priori (e.g. in PAAS deployments). In my app, for instance, I tell the client which server to hit (i.e. which server has his "app context" active) - I can't leave this decision to the LB which has no clue. Making these decisions "intelligently" instead of relying on LB's load balancing makes a huge difference in scalability. Thus to "target" connections one must take care also of all open requests.
In any case, LBs today have sticky sessions I'm not sure what is the new functionality introduced by this PR.

@crzidea
Copy link
Contributor Author

crzidea commented Jan 3, 2014

@mokesmokes This is third time I tell you cookies was not supported with cross domain JSONP even by IE10. I'm dealing with it.

@mokesmokes
Copy link
Contributor

You don't need cookies to support sticky sessions. You can also stick the session to a specific client IP address and this is how it's often done.

@crzidea
Copy link
Contributor Author

crzidea commented Jan 3, 2014

@mokesmokes That is not reliable. And we have to test it with 1M clients connections on a sigle 64G memory machine. IP based load balancing just targeting all of them to one node instance.That is a terrible way.

@crzidea
Copy link
Contributor Author

crzidea commented Jan 8, 2014

Already solved with following way:
socketio/engine.io#207 (comment)

@crzidea crzidea closed this Jan 8, 2014
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

Successfully merging this pull request may close these issues.

2 participants