Hello everyone, I am a bit stuck on how I should deal with cleaning up active game sessions with zero players in them. Before, I implemented game logic that would terminate a game session and end the server process if no players were in the game after a certain amount of time. Besides the obvious fact that it isn't necessarily good to constantly restart the server process, I realized that this created a few race conditions.
-
Players joining the game right before the server process exits. This occurs when players find a match and it takes a certain amount of time to join the game so that by the time they join, the timer function that checks for any players already got called, but the call to terminating the game session and ending the server process has not quite been reached yet.
-
Players join the game during the ending/termination of the server process/game session. Personally, I am still not sure if this can even happen, and even if it does, I think joining the server will end up taking so long that the client will ultimately join the restarted server process. I think in this case I should just kick the player out. Also, I am wondering if this may interfere with FlexMatch, if possible, because I did get a ticket with this error message, The game session null was not found, or was in a state which wouldn't accept new player sessions.
and was wondering if this scenario could have caused it.
-
Players join the game by the time the server process restarts. This case can be caused if the players got matched with a game session, but they took so long to join that the timer function that checks for any players already got called and thereby called the logic that terminates/ends the game session/server process. This tends to happen quite often, and I believe kicking the player out of the server is the best way to deal with this.
I have briefly looked into auto-scaling fleets with rule-based policies, but I am unsure if I will end up coming across the same race conditions outlined above. Especially since I have come across these forum posts that don't seem to have a concrete answer:
https://forums.awsgametech.com/t/asking-about-how-to-terminate-game-session/6931
https://forums.awsgametech.com/t/scale-down-policies/5233
Also, would it be possible to get a sample policy that scales down game sessions with no players? Thing is I want to be careful again, because I know clients joining the server takes time. That is why I mentioned the race conditions above. I know setting fleets to have full protection will protect game sessions with players. Does this mean game sessions with reserved and active player sessions are protected, or just game sessions with active player sessions? Lastly, I believe player sessions time out after 1 minute if they are not accepted within this time frame so perhaps these pieces of information may come in helpful for dealing with this. I know this was a lot, so thanks in advance.