question

Niklas Gawell avatar image
Niklas Gawell asked

GetQueueStatistics in CloudScripts seems limited not per user

We have added a cloudscript end point where we want to make decisions based on statistics for one of our matchmaking queues. We call this end point very seldom (once every few minutes per user). And as long as there is only one player using this we are fine, but when there are more than one we start being throttled. It seems the limit is imposed per queue, rather than per player. We could circumvent this by having the player get the statistics (that works without throttle) and post that the script, but that seems dumb.

I attach a screenshot here where you can see the pattern. It all succeeds until two players happens to use the end point within a minute, then it fails. The error message we see is attached below

          "apiError": {
            "code": 429,
            "status": "429",
            "error": "MatchmakingRateLimitExceeded",
            "errorCode": 2054,
            "errorMessage": "The rate of get queue statistics requests for title!C6A22 has exceeded the limit and is temporarily throttled.",
            "errorHash": null,
            "errorDetails": null
          }
CloudScriptMatchmaking
gdgg1.png (101.8 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Rick Chen avatar image
Rick Chen answered

There is a limit of Number of GetQueueStatistics API requests an entity can make per queue within a period of 1 minute. You can check it in [Game Manager]->[Your Title]->[Title Settings]->[Limit], the limit’s name is “Queue statistic gets per minute”. The limit is usually 1. The GetQueueStatistics API should be called by the server in your CloudScript, not by user. Therefore, no matter which user executes the CloudScript, the GetQueueStatistics API is called by the same server entity. And calling 2 GetQueueStatistics APIs in 1 minute produce the limit error.

It is not recommended to allow players to call GetQueueStatistics API via CloudScript.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Niklas Gawell avatar image Niklas Gawell commented ·

So it is not recommended to use queue statistics in cloud scripts? I do not understand that limitation, but I guess I can work around it.

0 Likes 0 ·
Rick Chen avatar image Rick Chen ♦ Niklas Gawell commented ·

The GetQueueStatistics API returns the matchmaking statistics for a queue. And the statistics are refreshed once every 5 minutes. Although GetQueueStatistics is an entity API, it is designed for servers only. You could use it in CloudScript, and one way to work around is to cache the result when GetQueueStatistics API is successfully called, and when it is not successful, catch the error and use the cache, for example:

handlers.GetQueueStat = function(args,context){
                    
try{
result = multiplayer.GetQueueStatistics({QueueName: args.QueueName});
title_data_result = server.SetTitleData({Key:"NumberOfPlayersMatching", Value:result.NumberOfPlayersMatching});
return result.NumberOfPlayersMatching;
}
catch(error){
result = server.GetTitleData({Keys:["NumberOfPlayersMatching"]});
return result.Data.NumberOfPlayersMatching;
}
}
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.