Using multiple nodes
Using multiple nodes
Sticky load balancing
If you plan to distribute the load of connections among different processes or machines, you have to make sure that requests associated with a particular session id connect to the process that originated them.
This is due to certain transports like XHR Polling or JSONP Polling relying on firing several requests during the lifetime of the “socket”.
To illustrate why this is needed, consider the example of emitting an event to all connected clients:
io.emit('hi', 'all sockets');
Chances are that some of those clients might have an active bi-directional communication channel like WebSocket
that we can write to immediately, but some of them might be using long-polling.
If they’re using long polling, they might or might not have sent a request that we can write to. They could be “in between” those requests. I