question

Kim Strasser avatar image
Kim Strasser asked

Should I call client API ExecuteCloudScript a few times one after another?

I need to call client API ExecuteCloudScript each time when the player logs in. Right now, I call client API ExecuteCloudScript 3 times one after another when the player logs in because I have 3 different CloudScript functions.

I do the following things in the ExecuteCloudScript calls:

-First ExecuteCloudScript call: I call Title Player Internal Data to get one key/value pair.

Then, I only make the next 3 client API calls if the player has a working account:

-Second ExecuteCloudScript call: I call Title Player Internal Data to get one key/value pair.

-Third ExecuteCloudScript call: I call Title Player Read Only Data to get one key/value pair.

-Fourth client API call, I call PlayFabProfilesAPI.GetProfile when the player logs in to get his profile language.

Would it be better to make less client API calls when the player logs in? I could change the Title Player Read Only Data call to a Title Player Internal Data call because the key/value pair doesn't need to be in Read Only Data.

Does it cost me more money if I do it like this? Would it be cheaper if I change my code and if I make less client API calls and if I would only use 1 CloudScript function for everything instead of 3 different CloudScript functions?

CloudScript
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

·
Sarah Zhang avatar image
Sarah Zhang answered

>> Would it be better to make less client API calls when the player logs in?

You can navigate to your title’s [Game Manager]->[Title Settings]->[Limits] or the URL - https://developer.playfab.com/en-US/c/[YourTitleId]/limits (please replace [YourTitleId] with your real title Id) to check the limits of your title. As the limits page showed, there are different limits on the different APIs. However, since the [limits] doesn’t provide the specific limits of frequency of cloud script execution. We would suggest you control the frequency according to the common limit of client API. Please check this thread - What is the limit of calls per second to the api? (executecloudscript) - Playfab Community to learn about the common limit of client API calls. For summary, the burst rate we allow currently is 100 client API calls in 2 minutes. If they are called to execute the CloudScript, we would recommend you try to consolidate the data retrieving operation into a single CloudScript. For your case, you can combine the Step 2 and 3 to one CloudScript function.

>> Does it cost me more money if I do it like this? Would it be cheaper if I change my code and if I make less client API calls and if I would only use 1 CloudScript function for everything instead of 3 different CloudScript functions?

For clarification, currently, if you launched a title, you can’t downgrade it anymore. And upgrading of the account paid plan may cause the subscription cost too. So, unless the players of your title exceed the limit of the free plan, we do not recommend you launch the title or upgrade the paid plan. The title in development mode is support up to 10 titles with up to 100k users per title. Please check the pricing page - Pricing (playfab.com) and the documentations - PlayFab Pricing Overview - PlayFab | Microsoft Docs, Billing Summary + Base Rate - PlayFab | Microsoft Docs, Development Mode - PlayFab | Microsoft Docs to learn more about our pricing models.

If the number of one title’s players have exceeded the limit of free plan, you would need to launch the title to continue. In this case, you need to choose the most cost-effective paid plan according to the description on the pricing page to save costs.

Then please check the documentation - Pricing Meters - PlayFab | Microsoft Docs to learn about how we would charge your title based on your consumption beyond the paid plan. Firstly, calling client APIs to execute CloudScript functions to read the player internal/read-only data will both increases the CloudScript costs and the Profile Reads. As this section – CloudScript said, the minimum billable memory size and execution time per execution is 128MB and 100ms, respectively. It means, yes, you can reduce the cost through combining the multiple server API calls to one CloudScript function. Please also check the limits page to make sure the number of server APIs in one function won’t exceed the limits.

Besides, you can check the section - Profile and the documentation - Profile Reads Meter API Description - PlayFab | Microsoft Docs to learn about how we charge you for the profile reads. As the above section said, profile reads are metered based on the total number of reads of profile data which are processed by PlayFab. You can refer to the documentation - PlayFab Consumption Best Practices - PlayFab | Microsoft Docs, spetically this section - Profile to learn about how to reduce the profile reads meters.

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.