Search code examples
amazon-ec2spring-websocketelastic-load-balancer

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


Solution

    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.