question

aymericvergne avatar image
aymericvergne asked

"Invocation of cloud script funcion [FUNCTION_NAME] failed with HTTP status TooManyRequests" occurs for all user at the same time

Hello !

I am working on a project that requires loading some information stored in a Cosmos DB database on Azure. To do this, we use an Azure function called using the PlayFabCloudScriptAPI.ExecuteFunction(), there are 4 or 5 calls made one after the other, waiting for the return of the previous one.

From time to time, without identifying a cause, the following return message occurs to all calls:

"Invocation of cloud script funcion [FUNCTION_NAME] failed with HTTP status TooManyRequests"

When this happens, all users are affected at the same time and no one can execute a cloudscript without receiving this error for a few minutes, then everything starts working again for everyone.

We are unable to identify which limitation is reached to generate this problem and if it is a limitation, why are all users affected at the same time? Does it come from PlayFab or the Azure Function? Is it a global limitation to all users and only a certain number of cloud script requests can be made at the same time for all users?

apisCloudScriptlimits
10 |1200

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

Infer Wang avatar image
Infer Wang answered

It’s frequent playfab API calls lead to title throttled which is set to protect title from DDos attack. You may reduce the frequency of calls in a short period of time.

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.

aymericvergne avatar image aymericvergne commented ·

Thanks for your reply but I would need some more details on it : So one user call the API too many times and the title is throttled for all the users not only the one making those requests ? Is 5 calls in few seconds too much ?

Some cloud script may use the playfab API. Are the frequent calls user <-> playfabAPI are causing that or is it the API calls cloudscript <-> Playfab API threw the server API ?
How this can shut down the access to Playfab API for all users and not the one making the calls ?

0 Likes 0 ·
Infer Wang avatar image Infer Wang aymericvergne commented ·

Too many requests will lead to rate limit, influence all the users in title. For details about rate limit, you may refer to this.

If it’s cloudscript’s call error, ExecuteCloudScript will return an error code named CloudScriptAPIRequestCountExceeded.

This event title_client_rate_limited_alert will be triggered, and users who have same Ip are throttled.

0 Likes 0 ·
Gavin Jensen (HE/HIM) avatar image
Gavin Jensen (HE/HIM) answered

@aymericvergne - Is your Azure Function getting throttled when calling into your CosmosDB instance? If an error is thrown inside of your Azure Function PlayFab will wrap it and return it to you as you are seeing when invoking ExecuteFunction. I'd suggest checking that you have enough RUs on your CosmosDB instance.

https://learn.microsoft.com/en-us/rest/api/cosmos-db/http-status-codes-for-cosmosdb

6637-image.png


image.png (83.7 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.

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.