Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Amazon ELB in TCP mode to spread websocket connections across multiple Tomcat-based websocket servers?

I've seen 3 different posts about using ELB with websockets, but they all seem to be using javascript clients or have some other variable which doesn't apply to our situation.

We have multiple websocket servers that are running in Tomcat. We wish to front them with ELB and have all websocket clients (i.e. 100s of 1000s) connect to the ELB, which needs to:

  • forward the upgrade request/connection to 1 of our websocket servers
  • then make that connection sticky so that all bi-directional traffic goes between the same client and server for the lifetime of the connection

Is this possible with ELB today? If possible, are there any special configuration/setup that needs to be done? What limits are there on the number of concurrent connections an Amazon ELB supports in TCP mode?

We have tried testing this in TCP mode, but beyond a few 100 connections, connections start failing. If we connect directly to a single websocket server, however, we can establish 80K (or more) websocket connections.

Thanks, Bob

like image 934
Bob DeRemer Avatar asked Nov 02 '13 01:11

Bob DeRemer


1 Answers

In summary, when connecting through ELB please be aware of the following:

  • if you expect a large number of connections, submit a support request to EC2 asking them to "pre-warm" your ELB. This requires filling out a form that provides them with the time window, # of connections, request/response msg sizes, msg frequency, and some other parameters. Under the hood, ELB is allocating machines capable of distributing the planned load across the configured backend instances
  • if you're connections are persistent (like we required with websockets), it is important to know that ELB has a 1 minute default idle timeout. After that time, if no traffic is seen, the connection is closed. You can request they increase that time to 15 mins. NOTE: this is why it's important to leverage a ping/heartbeat mechanism if connections need to be kept open longer than ELB will allow.
like image 142
Bob DeRemer Avatar answered Nov 10 '22 08:11

Bob DeRemer