2

I haven't really found a good solution to Websocket, socket.io connection with Elastic Load Balancer using Elastic Beanstalk running on node.js. Anyone has a good set up on how to scale node.js with socket.io implementation

Here are some question: if we use a load balancer with tcp listener, how can the socket.io establish the connection with https?

Really appreciate anyone who has tried this implementation setup to give some insights :) Cheers

Hong Zhou
  • 659
  • 1
  • 9
  • 20

2 Answers2

0

Yes, you can load balance TCP connections, and that may be enough. Keep in mind that ELBs have an idle timeout of 60 seconds and make use your protocol sends heartbeats more frequently than that.

If you do not know or control the websocket protocol, you may consider running your load balancers on EC2 (nginx, hipache,...).

Julio Faerman
  • 13,228
  • 9
  • 57
  • 75
  • How about the socket.io connection? Initial connection is by http/https and then upgrade to tcp connection for websocket. But the listener for the load balancer can't listen to the same port for http and tcp together. How do the socket.io connection gets establish? – Hong Zhou May 30 '14 at 07:00
  • It is the same port, just no longer HTTP but any protocol your application decides to use. – Julio Faerman May 30 '14 at 12:20
  • @JulioFaerman, how do you configure the ELB to ensure subsequent handshakes get passed to the correct instance on AWS – Yousef Oct 30 '14 at 19:42
  • @Yousef If the protocol is HTTP, you can use Session Stickiness with cookies, but for TCP there is no such thing. – Julio Faerman Oct 30 '14 at 19:56
0

Now-a-days there's socket.io-redis

https://github.com/socketio/socket.io-redis

Lotus
  • 2,596
  • 1
  • 22
  • 20