I am to be load balancing two node.js/Socket.io instances on different boxes with nginx running a simple notifications service with a retroactive event for new clients.
I don't think there will be any issues with the websocket connection type (which will be the primary method of connection) as the maintained connection negates the need for a session (apart from on a reconnect which doesn't worry me too much).
However there will be a problem with the polling fallback approaches as they rely on client sessions and with standard roundrobin load balancing there's (in this case) a 50% chance the next poll will come up as a new client.
ip_hash seems like it'd do the job but I can see it having potential issues with mobile clients who either swap IP addresses whilst on 3G or that change between the mobile network and WiFi thus changing IP address.
I have a couple of questions tied in with this; if you can answer either that'd be great...
- Does ip_hash have any kind of lifespan, or does an IP address get permanently assigned to a backend instance?
- Can anyone share experience/recommendations on using nginx load balancing with Socket.io and/or mobile clients?