ALB route socket connection to the same server

Viewed 130

I'm trying to horizontally scale my socket application with an application load balancer in front. since it's a room-based application, I want to route all the participants in the same room to the same ECS task instance. here's a simple flow user1 create a room1 and alb decides to redirect to ecs_task1, then user2 wants to join room1, using id: room1, alb should redirect user2 to the same ecs_task1 so they can be on the same instance. after some research I find was alb can support some listening rules, and I think path-pattern might be able to work. so my logic is to bind room1 to the id of the task_id of ecs_task1 and using that as the path-pattern. however, then when the socket connection starts, I will need to bind the path using socket.of('<task_id>') and from the server end I will want to ignore the that task_id or listen on some sort of wildcard path right? I can't seem to find a support for wildcard path for socket io to listen on. is that doable? or steping back a bit, is this a good architecture to handle the socket with room?

0 Answers
Related