Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

Rather than syncing the sessions across the two boxes, it makes sense to me to have the load balancer do some semi-intelligent routing using either the ip_hash directive or nginx-sticky-module.

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...

  1. Does ip_hash have any kind of lifespan, or does an IP address get permanently assigned to a backend instance?
  2. Can anyone share experience/recommendations on using nginx load balancing with Socket.io and/or mobile clients?
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.