question

Brian Davis avatar image
Brian Davis asked

What was original intended use of Cloud Script?

My eyes have recently been opened to PlayFab's pricing model. It's something I really just sort of skimmed over as I've been learning how to integrate PlayFab into an app, but I thought it would be a very good to learn before progressing any further. The pricing for Cloud Script executions got me thinking.

When I first learned of Cloud Script, my initial thought was "This is awesome! I can use Cloud Script for metrics-based bookkeeping." I mean, the examples of using Cloud script on PlayFab's website are short, clear, and concise. They don't take much memory and likely have very fast processing time. It would be perfect for my needs.

And it does work for my needs, but having recently put two and two together, I learned that EACH Cloud Script execution has a "minimum billable memory size and execution time [of] 128MB and 100ms, respectively". That has a potential of adding up very quickly depending on the individual implementation of Cloud Script in an application.

I cannot help but wonder what the original intention of the Cloud Script functionality was? For instance, using it for metrics type stuff with a 200 byte (if that) script clearly does not seem to fit the intended usage. It just seems that execution of small scripts wasn't the main focus of this really cool feature.

10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

CloudScript is mainly intended for running server-authoritative logic from a client device or a server, or being triggered by PlayStream Rules so that it can perform some real-time in-game logics based on player events. In general, the use of CloudScript is mainly centered on taking actions on behalf of the players.

As opposed to custom game server hosting, you’d only need to pay the GB/s you used. Regarding on the minimum billable memory size and execution time, which is 128MB and 100ms respectively, that’s pretty much the standard in the Faas (Functions as a service) world and it really doesn’t cost very much (400K/1M GB-s and $0.00002/$0.000019 per additional GB-s for Standard and Premium plan respectively). The total memory used is not the memory consumed by a single function script, rather, it’s the size of the total script, plus all memory allocations within it & some overhead for the V8 engine itself (CloudScript is a set of JavaScript functions compiled with V8 and hosted on PlayFab's servers).

BTW, I noticed that you opened this thread: https://community.playfab.com/questions/43553/how-are-memoryconsumedbytes-and-other-cloudscript.html?childToView=43562#comment-43562, did Brendan's reply answered your questions?

10 |1200

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

Max Guernsey, III avatar image
Max Guernsey, III answered

I use vanilla Azure Functions, which are very similar to Cloud Script. If my understanding is correct, they are the same thing but called by different names.

I use Azure Functions to host my game logic so my game is server-authoritative.

It seems like each Azure Functions subscription is billed separately and there is a free allotment of work for each subscription that seems to work out to about a million hits. So, theoretically, you could deploy each function to its own subscription (or whatever the boundary-creating entity is) and get a million hits against each, free.

I can't really verify that because I haven't created enough traffic to generate real cost and because I deploy them all to the same subscription. That said, the cost of $.20/million hits after the first million seems pretty manageable, for me.

I'm sure someone from PlayFab will chime in with a proper answer to your question (as only they can answer the question you asked) but I think the costs are pretty fair, if extant at all, and I suspect the original and current intentions have to do with retaining control over the execution environment for certain critical behaviors.

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.