Turning off automatic backfill near end of game session (FlexMatch matchmaking)

Hi, I have enabled “automatic backfill” in my matchmaking configuration per the instructions in the docs: “Turn on automatic backfill” section of https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-backfill.html. The backfilling itself works well. Calls from my client service to “StartMatchmaking” will, when expected, return a match to an existing game session. The problem I’m trying to solve now is that I don’t want players to be backfilled into a game that’s almost over. Item #4–“Turn off automatic backfill for a game session”–doesn’t seem to work when I try to implement it on my game server:

4. Turn off automatic backfill for a game session. You can opt to stop automatic backfill at any point during an individual game session. To stop automatic backfill, add code to your game client or game server to make the GameLift API call StopMatchmaking. This call requires a ticket ID. Use the backfill ticket ID from the latest backfill request. You can get this information from the game session matchmaking data, which is updated as described in the previous step.

What confuses me here is that I want to stop backfilling near the end of the game regardless of whether the game session has backfilled any players yet. The line “Use the backfill ticket ID from the latest backfill request” doesn’t make sense if no backfill tickets have been received in the game session.

Intuitively, it feels like there should just be some API I can call that opts a particular game session out of future backfill requests but I’m not seeing it.

Any help would be greatly appreciated.

Hey, so for stopping backfill in this situation, I believe that it would be better handled by the server through the server SDK, not the client service. Yes, you can call StopMatchmaking from the client/client service while passing the backfill ticket id but since you want the server logic controlling when backfill stops (in this case when the game is almost over), I would recommend taking a look at either calling StopMatchBackfill in the gamelift server SDK or calling StopMatchmaking in the AWS SDK from the server.

1 Like

@chrisgong Thanks for the response! Although I call “StartMatchmaking” from the client, I am calling StopMatchBackfill from the server just as you mentioned. Unless I’m missing something this call requires a ticket id which doesn’t make sense to me in the context of automatic backfill (what if no backfill has happened so far at the point I want to cancel). Are you suggesting that I switch to managing manual backfill from the server?

So for automatic backfill, unless things have changed since I last experimented with it, when a match is made, if there is still player capacity, one backfill ticket will be created automatically that lasts either until the end of the game session or until the backfill request gets fulfilled/expires. But afaik, your server won’t get the backfill ticket id directly. Technically, whatever’s subscribed to the SNS topic that receives FlexMatch event notifications will get information about the backfill ticket but since you want to stop backfill conditionally, it would probably be easier to do manual backfill in order to call StopMatchBackfill with a matchmaking request ticket id. In this case, that ticket id would be returned from a call to StartMatchBackfill. Hopefully, someone from AWS can shed some more light on this topic but what I remember is that automatic backfill is somewhat limited.

1 Like

@chrisgong Thanks again! I’ve actually shifted gears to using manual backfill (set in my matchmaking config) and calling StartMatchBackfill from the server as you suggested. It seems to work but I’m having issues with getting the manual backfill to fill slots of players that have left the game. That is, if 6 players join a game session with a maximum capacity of 6 and 1 player leaves the game, the backfill is apparently not filling that slot. A backfill ticket remains outstanding and does not fail but it is never filled. Any ideas of how I get around this?

Backfill requests are basically like regular matchmaking requests. In the case you specified, you would have to make a new backfill request (after canceling the current backfill request) to account for that player leaving because the existing backfill request won’t automatically adjust to that since the matchmaking is independent of the game server/player logic. If you don’t make a new backfill request, then the old one is going to continue to be processed by flexmatch and gamelift will keep trying to backfill the original 6 players.

1 Like

@chrisgong I am making a new backfill request with each new player session (provided the game session still needs players) but I’m realizing that I am getting the player list that I present to StartMatchBackfill from the DescribePlayerSessions API which returns player sessions that have ended along with the active ones. I’m thinking that the matchmaking process must reference the request to know how many players are currently in the game session. I’m guessing that if I make sure only to include active players in the request, all will work out. Thanks for the help!