Reputation: 6686
I'm running a chat application which allows clients to create rooms using websockets. I want to use aws elastic load balancing, but I'm not sure how to make sure two clients who want to chat end up on the same server. Specifically avoiding the following scenario:
I've looked at proxy protocol, but seems too complicated for my level and I'm not sure if that's what will fit my purpose.
Upvotes: 0
Views: 818
Reputation: 6686
I talked to some guys from amazon and they just suggested using the load balancer first when creating chat rooms and getting the server ip where it's created and passing it to client B to connect directly to that server. It worked perfectly!
Upvotes: 1
Reputation: 2145
It is not possible to do what you want with only a ELB. There is no way to make sure 2 clients end up on the same server.
I can see 2 options:
Create shared state between the node behind the elb. The chat room will be visible on all server and you should make sure every message send in a chat room is send to all instance that have client connected to the room.
Create a chat room management and discovery service. It will be responsible to select a server when the room is created and redirect the user when he want to connect to a room. You can simplify it by putting the server in the chat room location and create a very simple logic client side for server creation but this will limite correct balancing.
For a full HA and scaling system you will probably need both.
Upvotes: 0