Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loadbalancing web sockets - AWS Elastic Loadbalancer

I have a question about how to load balance web sockets with AWS elastic load balancer.

I have 2 EC2 instances behind AWS elastic load balancer.

When any user login, the user session will be established with one of the server, say EC2 instance1. Now, all the requests from the same user will be routed to EC2 instance1.

Now, I have a different stateless request coming from a different system. This request will have userId in it. This request might end up going to a EC2 instance2. We are supposed to send a notification to the user based on the userId in the request.

Now,

1) Assume, the user session is with the EC2 instance1, but the notification is originating from the EC2 instance2. I am not sure how to notify the user browser in this case.

2) Is there any limitation on the websocket connection like 64K and how to overcome with multiple servers, since user is coming thru Load balancer.

Thanks

like image 963
user1578872 Avatar asked Apr 24 '17 20:04

user1578872


People also ask

Does AWS load balancer support WebSocket?

Application Load Balancer (ALB) From its documentation we know that “The Application Load Balancer supports two additional protocols: WebSocket and HTTP/2,” and “it provides native support for WebSocket via the ws:// and wss:// protocols.”

Can WebSockets be load balanced?

The load balancer knows how to upgrade an HTTP connection to a WebSocket connection and once that happens, messages will travel back and forth through a WebSocket tunnel. However, you must design your system for scale if you plan to load balance multiple WebSocket servers.

What one thing can you not do using an AWS Elastic load balancer?

A: You cannot load balance to EC2-Classic Instances when registering their Instance IDs as targets. However if you link these EC2-Classic instances to the load balancer's VPC using ClassicLink and use the private IPs of these EC2-Classic instances as targets, then you can load balance to the EC2-Classic instances.

Which load balancer is best suited for HTTP HTTPS load balancing traffic?

Application Load Balancer can redirect an incoming request from one URL to another URL. This includes the capability to redirect HTTP requests to HTTPS requests, which allows you to meet your compliance goal of secure browsing, while being able to achieve better search ranking and SSL/TLS score for your site.


1 Answers

  1. You will need something else to notify the browser's websocket's server end about the event coming from the other system. There are a couple of publish-subscribe based solution which might help, but without knowing more details it is a bit hard to figure out which solution fits the best. Redis is generally a good answer, and Elasticache supports it.

  2. I found this regarding to AWS ELB's limits: http://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html#limits_elastic_load_balancer But none of them seems to be related to your question.

like image 142
Lajos Veres Avatar answered Dec 15 '22 21:12

Lajos Veres