Hello,
I have a web-based game platform that relies on WebSockets. In this game, a group of users (up to 10) can be matched together in a room to play a game against each other. There can be more than tens of thousands of players playing the game at the same time.
I have been using the default load balancer service provided by my cloud platform which distributes user connection to one of many available HTTP servers in the backend. When 10 users, who are in the same room, end up in different backend HTTP servers, the servers communicate with each other using Messaging platform (something similar to Apache Kafka) to relay and communicate actions happening within a room.
Things are working fine, but this approach has few issues.
- Messaging platform can become a bottleneck when we scale. (As # of backend server increases, the messaging platform has to do substantially more work to pubsub messages)
- Messaging platform adds latency.
Therefore, I am looking for a solution to see if I can somehow route users who are supposed to be in the same room to the same backend game server. If all users/players from the same room are connected to the same server, there is no more need for an inter-server messaging platform.
So my requirements would be something like
- If no player has joined for a room or match A1 yet, then the first player to join can end up in any one of the backend HTTP servers, preferably one with the least conn.
- When there is at least one player already connected to backend server S1 for match A1, HAProxy should forward later joining players to server S1.
- The number of backend servers up and running can change any time before/during/after when 1 and 2 are happening.
While I do not have a good understanding of load-balancer, nor reverse-proxy, I learned about HAProxy and started reading its documentation, but I couldn’t figure out if HAProxy will be able to support my use case. As far as I can tell, HAProxy’s hash-based load balancing can route same-hash requests to different servers if # of servers in the backend change.
Would HAProxy be able to fulfill my use case?
1 post - 1 participant