- Newest
- Most votes
- Most comments
I asked someone on the GameLift team via email about this topic and thought that it would be good to post his response here:
Right, there are two pieces of important documentation; SNS notification format here, and the Flexmatch message format here. The SNS notification contains the entire Flexmatch message in the “Message” field. Each has a timestamp. The SNS message timestamp field is called “Timestamp”, and is the ‘publish’ time when SNS received the message. The message had to be sent before that. And it had to be constructed even before that, so the Flexmatch message contains the “time” field, which should be earlier, when the Flexmatch message was constructed before it was sent.
The Flexmatch message “time” field is therefore the one to use if comparing times.
However...
I don’t exactly know if these messages can be generated in parallel for a given ticketID, and frankly I doubt it, but subsequent messages can definitely be generated within a millisecond of each other, meaning that due to the resolution of the timestamp string (which is 1 millisecond), two messages can have the same timestamp on them, for the same ticket ID. Nothing stopping that, and I believe this is often what is happening for the customer.
For example, I expect it to be highly likely that AcceptMatchCompleted is generated at almost the exact time that MatchmakingSucceeded is. It could be pretty common for their order to be ambiguous in SNS, and/or the “time” field to be identical in the Flexmatch messages.
In the case that the tie can only be broken by the logical ordering of the message types.
This order is:
MatchmakingSearching
PotentialMatchCreated
AcceptMatch (noting that multple AcceptMatch can be generated, and if the time stamps are identical then they cannot be ordered)
AcceptMatchCompleted
MatchmakingSucceeded | MatchmakingCancelled | MatchmakingTimedOut |MatchmakingFailed (only one of these ‘final result’ notifications will be generated for any given ticket).
My advice is only to subscribe to, and only to store the final result notification, if possible, as they are the only actionable ones. The others can be considered noise. If the game is using player acceptance ( e.g. to implement a block list) then it must also subscribe to and respond to PotentialMatchCreated. In the SNS subscription, set up a ‘Subscription filter policy’ to only receive notifications of actionable types.
If that doesn’t work for the customer, and it really should, then for those notifications whose type implies an order, then the Lambda should test the type of the message already stored and ATOMICALLY write the newly received one only if there is no later message stored as implied by the message type. This isn’t my preference for performance reasons, but it is a catch-all.
I hope this is okay. If I have to credit the person who said this by name, then I will edit my post to do so. Just wasn't sure if he wanted to be highlighted in this forum post 😛
Relevant content
- asked 5 months ago
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated 4 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago