Is it better for a realtime multiplayer game server to send game statistics outbound via a socket or wait for an inbound socket connection?

Viewed 32

I would like to report the number of players in each of my game server nodes to a central authority that will be used to load balance connections to those nodes. This is a real time multiplayer web game. This is a game design question for a game that could go in any load balance direction and at this point any solution is possible. At a high level if you were designing this would it be better to open an outbound tcp connection to the authority and report game stats in the game loop OR would it be better to wait for the authority to ask the game server for stats over an incoming tcp connection? Which solution would be better if you had 1000 nodes?

If this were outbound from game server: If the game server reports that this is my ip address, my port and my number of players the authority could catalog that data and update the number of players if the same ip/port combo exists. In order to prevent security issues with rogue agents reporting themselves as game servers you would then need to try and secure the connection with both encryption and some type of authorization mechanism.

If this were inbound to the game server If the authority already knows the address of each node it needs to connect too then you may only need to worry about man in the middle servers pretending to be the authority. Given the data is only game stats though and nothing sensitive, encrypting it shouldn't matter in the grand scheme for a connection inbound to a game server. I could have for example a config file or database table with all the known game servers to connect too. A mitm would get game stats or maybe just block the connection. To me this seems like the better option to just connect out to your game server unencrypted and get the stats. The downside is anyone else could connect to your game server as well to ask for game stats. Then in your game server you'd have to figure out either which connection is the real authority or just broadcast the game stats to anyone asking for game stats. The game server from a security standpoint though could get overloaded with to many connections wanting to get game stats and you don't have a good way to know which authority is the one that matters for your load balancing vs adhoc agents. I FEEL LIKE THIS IS THE WAY TO GO.

1 Answers

I agree that inbound to the game servers are the way to go, for the reasons you stated.

Here are a few other considerations.

  1. I think practically that it is a lot harder for the servers to connect to users' hosts because of ip changes and firewalls at the user-local level.

  2. You should always encrypt your customer's over the wire. And speaking of MITM, you should have some way of preventing one user from spoofing another user. No-one wants their game play taken over by a hacker.

  3. You could have, as part of your client-server protocol, a way for the server to dictate a minimum wait time before the client sends their next update.

  4. You could have the client updates put into a queue (rabbit, kafka, etc.) and have the servers update at their own capabilities. Queues are a lot more forgiving of elastic traffic, if you can handle them.

Related