kevinbaxtrom avatar image
kevinbaxtrom asked

Cloud Script Execution Time Limit - Errors

We started receiving notifications for a cloudscript event. We trigger this function on player login and it's been there for some time. We recently started getting notifications that it doesn't complete in 1 second. It's not doing a whole lot, but it does make to API calls. We are using this to inject the players last known location into their publisher data.

Is there anything that has changed in the last week that might cause this?


Resource: CloudScript execution time (triggered action)
Limit: 1 seconds
Requested: 1.06 seconds
Details: Timestamp: 2020-02-07T03:19:26 UTC
Associated player ID: 994C3E986D0ECBF0
Function: "copyLocationToPublisherData"

10 |1200

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

Andy avatar image
Andy answered

A couple of things:

1. We recently fixed a bug that was preventing some Limit-Exceeded alerts from being sent. That likely explains why you just started getting the notifications.

2. In this case, I would expect the overall incidence of these errors to be very low (from this function). It is possible for any API call to timeout, and they will at a non-zero rate (as will any call made over a network).

Of the two calls, the Update is far more likely to exceed the timeout. If it's the second call, that means the work is still going to be done, despite the cloud script timeout. If it's the first call, you'll need to evaluate your comfort level with the Get call sometime not occurring. If you really need the Get to succeed, you'll need to look into way of executing the call that can be reliably retried (such as invoking it from a client cloud script call).

That's a bit complicated, so if you need further explanation, let me know.

10 |1200

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

kevinbaxtrom avatar image kevinbaxtrom commented ·

Hi Andy thanks for the response,

I just want to clarify that the Update is the second call in our script. Is it possible that the GetCall is also failing or should we be able to rely on this completing in < 1 second? If the time limit is exceeded while the UpdateUserPublisherData() is in progress does the call complete?

Pseudo code of our function. We're not doing anything complex. We're just pushing the location from the eventContext into the publisher data:

val data = GetUserPublisherData()

data['LastKnownLocation'] = eventContext.Locations[0];


0 Likes 0 ·
Andy avatar image Andy ♦♦ kevinbaxtrom commented ·

The Get call should be reliably completing in < 1 second. Then, as long as the second request happens, it will complete, even if the function exceeds 1 second in the middle of the call. We don't abandon the call partway through, similar to how the call would still happen if you're were making it from a client that got shut down before the response was sent.

0 Likes 0 ·
gestion avatar image gestion Andy ♦♦ commented ·


I posted the question 37840 yesterday and looks like someone made it redirect to this one but I don't see why this question/answer explains what I queried.

What I get from here is that any Update function (UpdateUserData in our case) is more likely to exceed time limit than other calls and that it will get completed anyway, but how does that affect the tier we are in? Are we gonna get charged the 20$/mo for an action triggered cloudscript function that only has one Update API call because we cannot control wether it will be executed under 1s? Because that is a really simple/short function and things will probably get more complicated further ahead.

I'm not complaining, I just want to get things clear so I can inform my manager about our PlayFab needs. We are using the Essentials tier but I must check wether we need to upgrade each required feature separately (we will probably get the inventory upgrade before next release of our app) or directly jump to the Indie tier.

Any information on this will be appreciated.


0 Likes 0 ·
Show more comments
Tuomas Karmakallio avatar image
Tuomas Karmakallio answered

I am struggling with this issue as well. Trying to try->catch the timeout error does not work ( I had the idea of catching the player affected and tagging them ). Very frustrating, as it is happening at least once a week or more with a really simple script similar to yours, average 30-40 ms execution time.

10 |1200

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

gestion avatar image gestion commented ·

Hi @Tuomas Karmakallio. We were told to use Azure Functions as a workaround, because the queued functions would execute completely without time spikes warnings.

Unfortunately, we get the following error:

/CloudScript/ExecuteFunction: The function TestAzureFunction was terminated after the maximum execution time limit: 10000ms

The weird thing is that we are using the function on the Azure docs (which basically is a Hello World function with a parameter) but it gives us the 10s execution time.

The PlayFab docs just refer to the Azure docs, and besides the section about linking to the function from PlayFab we haven't been able to find a way to use the queued functions from inside a script in Unity.

We will keep investigating, mainly because we cannot control the spikes and we need a way to execute our functions (we went from 60ms to 2s spikes on CloudScript and now 10s on AzureFunctions, apparently, that's crazy).

1 Like 1 ·
Shaiv Kamat avatar image Shaiv Kamat gestion commented ·

Some of the issues when moving from ClouScript to Azure is cold starting your function calls. If its been a while since the function has been hit the cold start time (varies per language) can near or exceed 10s. You can build your own warming code (,must%20wait%20for%20their%20function.) or switch your hosting Plan from Consumption to Premium which should allow bypass any cold start issues.

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.