question

cm avatar image
cm asked

Is cloud script execution time expected to be within range of 800-1000 ms?

During testing of playfab i call the following code to test expected responce time and the result i get is close to 1 sec. is this to be expected?

setInterval(() => {<br>    const start = Date.now();PlayFabClient.ExecuteCloudScript({FunctionName: 'helloWorld'}, (err, data) => {<br>        if (err) {<br>            console.error('Failed to execute cloud script', err);} else {<br>            console.log('Executed', Date.now() - start);}<br>    });}, 3000);
apisCloudScript
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.

cm avatar image cm commented ·

Something went wrong when i clicked login and post. that's why the title and questing is duplicated.

0 Likes 0 ·
brendan avatar image brendan cm commented ·

AnswerHub is working on an update to their editor which should help with this. They haven't given us a date for that yet, but we're hoping it'll be this quarter.

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

Well first, that code doesn't check the execution time of the script, it's checking the time to get the response to calling ExecuteCloudScript, which is very different. The actual execution time of the script is returned as

The time a Cloud Script handler takes to return is dependent upon a few things:

1. Any calls made out of the server, whether to a Server API call or a third-party service. The time those take to return will be variable, and the Cloud Script will wait on the response to continue.

2. The complexity of the JavaScript. If the logic is trivial, this would be negligible.

3. Your Internet connection and location. Your latency to the service itself can introduce a significant latency to the call - one way to check this is via http://www.cloudping.info/ (our core service is in US-West Oregon).

4. Whether you've hit any Cloud Script handler in a while (it's not a fixed value, as its based on usage). If you haven't, the Cloud Script for your title may no longer be loaded on the logic servers, in which case it needs to be copied from your title's data to the logic server before it executes. For a very large Cloud Script file, that could take a few seconds.

Of these, only 1 and 2 impact the execution time of the script handler.

4 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.

cm avatar image cm commented ·

We are currently comparing BaaS services and don't see this kind of consistent latency in any other service / Cloud functions. For comparison we tested Google Cloud Functions to take ~150ms under same conditions.

0 Likes 0 ·
brendan avatar image brendan cm commented ·

I'm not sure what you're looking for in this case. Of the items I listed, 1 is invariant - any calls outside the server hosting the logic will take the same amount of time, regardless. The same is true of 3, since the connection to any given endpoint determines the latency. Item 2 can be changed by the capabilities (most often the CPU speed) of the server running the logic. Item 4 is due to the nature of our service, in order to keep costs down. If we maintained all Cloud Script revisions for all titles for all time, even if they never make any calls, we would be paying considerably more for those servers, and so have to increase our prices - which we don't want to do.

PlayFab provides a rich set of backend features for game developers and made by game developers, and as inexpensively as possible. We keep that cost low by operating the core service in a single region - though in multiple availability zones, for safety.

But it's also worth noting that PlayFab is not a monolithic platform. You should feel free to use only the components you need.

0 Likes 0 ·
cm avatar image cm brendan commented ·

Thanks for the quick answer.

So to clarify, do you load and parse the cloud script file for every call? this could explain the relative long response. i have only tested with the standard examples revision.

We are currently developing a turn based card game with some near real time features. eg. other players see a card shake when the current player hovers a card. We er evaluating which BaaS whould help us run the "server" / non client code for this

/Moberg

0 Likes 0 ·
Show more comments

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.