title: Node socket.io on load balanced Amazon EC2
body: <p>I have a standard LAMP EC2 instance set-up running on Amazon's AWS. Having also installed Node.js, socket.io and Express to meet the demands of live updating, I am now at the stage of load balancing the application. That's all working, but my sockets aren't. This is how my set-up looks:-</p>
  
  <pre><code>                  --- EC2 &gt;&gt; Node.js + socket.io
                  /
  Client &gt;&gt; ELB --
                  \
                    --- EC2 &gt;&gt; Node.js + socket.io
  
  
  [RDS MySQL - EC2 instances communicate to this]
  </code></pre>
  
  <p>As you can see, each instance has an installation of Node and socket.io. However, occasionally Chrome debug will 400 the socket request returning the reason <code>{"code":1,"message":"Session ID unknown"}</code>, and I guess this is because it's communicating to the other instance.</p>
  
  <p>Additionally, let's say I am on page A and the socket needs to emit to page B - because of the load balancer these two pages might well be on a different instance (they will both be open at the same time). Using something like Sticky Sessions, to my knowledge, wouldn't work in that scenario because both pages would be restricted to their respective instances.</p>
  
  <p>How can I get around this issue? Will I need a whole dedicated instance just for Node? That seems somewhat overkill...</p>