question

Brian Davis avatar image
Brian Davis asked

How are MemoryConsumedBytes and other cloudscript result values calculated?

I'm trying to wrap my head around the PlayFab pricing model. Currently I'm looking a few things.

First, the cloudscript execution results and the generated data for execution time and memory consumption. The time calculation is fairly evident, but if the processors are being particularly taxed, it seems that longer execution times could result. That would result in higher GB-s for a given cloudscript execution, correct?

The memory consumption calculation is a complete mystery, and I haven't been able to find anything about the inner workings of how the value is actually calculated.

What concerns me is that in my evaluation of PlayFab, I really haven't used it in what I would consider to be an overly taxing manner, yet it is barely a week into August and I'm sitting at 5.4GB-s (just me, no other players). The month of July was 23.04 GB-s.

Are the cloudscript usage values calculated based on any use of them regardless of from the web front-end or via code? What can be done to lower that number? For instance, how can I determine that "X" cloudscript handler is being called an unusual amount of times so that I can properly address the issue and not wind up with skyrocketing GB-s?

Thanks!

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

·
brendan avatar image
brendan answered

First, I'd recommend using Azure Functions Cloud Script, as it has a number of advantages. Better monitoring and reporting for things like this is one of them. For legacy Cloud Script, the total memory used will be the size of the total script, plus all memory allocations within it, plus some overhead for the V8 engine itself. For runtime, it's a single-threaded process in a single VM, so the CPU consumption is the same throughout its runtime. As to how hard the CPU is being hit depends upon what you're doing. For example, if you make an http.request() call, the CPU is going to be idling while you wait on the response to that external call, but that's still consumed runtime, since the engine is 100% dedicated to your script until it's done.

But all that aside, I suspect you're not exceeding the base memory per execution, which is 128 MB (https://docs.microsoft.com/en-us/gaming/playfab/features/pricing/consumption-best-practices). That's the same, regardless of whether the call is in legacy or Azure Functions Cloud Script. If so, your 5.4 GB-s would be right around 42 seconds of total script runtime. But 1 second is time for quite a lot of processing on a server, so apart from deliberate "wait" periods (like calling http.request), many game processes we see in Cloud Script are well under a second. So the 400K/1M GB-s you get with the Standard and Premium accounts is often more sufficient for quite a few game types (Premium would be for when you have a large player population, and so need more resources). If you find that you need much higher server-side compute times per player due to long processing jobs and/or very frequent calls, you may want to consider switching to using hosted game servers, as that may be more economical for your design.

In terms of how often a handler is being hit, if you're using Azure Functions Cloud Script, you can monitor it via the telemetry tools available in Azure (https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring?tabs=cmd). For legacy, the API graph on the main dashboard of your title gives you the ability to check on how often Cloud Script execution calls are made, and review any error frequencies, and the Cloud Script (Automation) page shows the breakdown of handlers called in the last 24 hours, along with any errors.

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.

Brian Davis avatar image Brian Davis commented ·

Thanks for that info. Any advice on how to specify Azure Cloud Script vs Legacy? I'm using the PlayFabEditorExtensions Unity package currently.

0 Likes 0 ·
Brian Davis avatar image Brian Davis Brian Davis commented ·

Thanks again, @Brendan. I found the information I need at https://docs.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/quickstart.

I'll follow their quickstart and see what I need to do in order to migrate. As far as everything else goes re PlayFab and the Unity extensions package is concerned, are there any other changes to consider?

0 Likes 0 ·
brendan avatar image brendan Brian Davis commented ·

Not really. Moving to Azure Functions Cloud Script gives you quite a bit more flexibility, so it should actually make your life easier. But that said, if you run into any Unity-specific issues, please do let us know.

0 Likes 0 ·
Brian Davis avatar image Brian Davis commented ·

*But all that aside, I suspect you're not exceeding the base memory per execution, which is 128 MB"

That is very likely to be the case.

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.