Question

When having a bunch of systems that act as WebSocket drones and a Load Balancer in front of those drones. When a WebSocket request comes into the LB it chooses a WebSocket drone, and the WebSocket is established. (I use AWS ELB tcp SSL-terminated at ELB)

Question: Now does the created WebSocket go through the LB, or does the LB forward the WebSocket request to a WebSocket drone and thus there is a direct link between client and a WebSocket drone?

If the WebSocket connection goes through the LB, this would make the LB a huge bottleneck.

Removing the LB and handing clients a direct IP of a WebSocket drone could circumvent this bottleneck but requires creating this logic myself, which I'm planning to do (depending on this questions' answers).

So are my thoughts on how this works correct?

Was it helpful?

Solution

AWS ELB as LB

After looking at the possible duplicate suggested by Pavel K I conclude that the WebSocket connection will go through the AWS ELB, as in:

Browser <--WebSocket--> LB <--WebSocket--> WebSocketServer

This makes the ELB a bottleneck, what I would have wanted is:

Browser <--WebSocket--> WebSocketServer

Where the ELB is only used to give the client a hostname/IP of an available WebSocketServer.

DNS as LB

The above problem could be circumvented by balancing on DNS-level, as explained in the possible duplicate. Since that way DNS will give an IP of an available WebSocketServer when ws.myapp.com is requested.

Downside is that this would require constantly updating DNS with up/down WebSocketServer changes (if your app is elastic this becomes even more of a problem).

Custom LB

Another option could be to create a custom LB which constantly monitors WebSocketServers and gives back the IP of an available WebSocketServer when the client requests so.

Downside is that the client needs to perform a separate (AJAX) request to get the IP of an available WebSocketServer, whereas with AWS ELB the Load Balancing happens implicitly.

Conclusion

Choosing the better evil..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top