question

Kim Strasser avatar image
Kim Strasser asked

CloudScript and Azure Functions costs?

Is it possible to find out how much a specific CloudScript or Azure Functions call costs?

For example, I have this json data from the PlayStream event player_executed_cloudscript:

{
  "PlayFabEnvironment": {
    "Application": "logicserver",
    "Vertical": "master",
    "Commit": "22da35e",
    "Cloud": "main"
  },
  "EventNamespace": "com.playfab",
  "CloudScriptExecutionResult": {
    "FunctionName": "GetPlayerAvatar",
    "ExecutionTimeSeconds": 0.0539539,
    "ProcessorTimeSeconds": 0.0,
    "MemoryConsumedBytes": 15240,
    "HttpRequestsIssued": 0,
    "APIRequestsIssued": 1,
    "FunctionResult": {
      "callsuccessful": true,
      "avatarnumber": "6",
      "errorresult": null
    },
    "Revision": 71,
    "Logs": [
      {
        "Message": "avatar code is: 6",
        "Level": "Info"
      }
    ]
  },

Is it possible to calculate the costs with these informations?

I have read this article: https://docs.microsoft.com/en-us/gaming/playfab/features/pricing/meters/meters

But I don't understand how to calculate the costs for CloudScript or Azure Functions calls myself.

How can I calculate the costs for CloudScript?

How can I calculate the costs for Azure 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

To calculate the cost, you need to calculate the GB-s of CloudScript Execution Time that consumed by you. As this thread -- https://community.playfab.com/questions/42100/cloudscript-execution-time-pricing.html said, the minimum execution time and memory for a single function execution is 100ms and 128mb respectively. So, each script execution would consume 0.0128GB-s at least. In your example, the value of ExecutionTimeSeconds is 0.0539539 that equals 53.9539ms. It is less than 100ms. This execution consumes 0.0128GB-s.

As our documentation -- https://docs.microsoft.com/en-us/gaming/playfab/features/pricing/development-mode said, the development mode title has the free quota of 20K GB-s CloudScript Execution Time and 200K Executions. For the launched title, different subscription plans have different limits. Please navigate to this page -- https://playfab.com/pricing/ for more details. For example, in Pay-as-you-go plan, the pricing of CloudScript Execution Time would be $0.000022 per GB-s and $0.22 per million executions. The cost of your example would be 0.0128*0.000022+ 0.000001*0.22.

The cost of Azure Functions will be charged by Azure, please check this documentation for more details. If you have more questions about the cost of Azure Functions, please contact the support of Azure.

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

Kim Strasser avatar image Kim Strasser commented ·

I have a question about estimating the cost if 10000 people would execute the same CloudScript function 20 times per month.

Your example for 1 person who executes this CloudScript function 1 time per month:

 0.0128*0.000022+ 0.000001*0.22 = 0.0000005016$<br>

Example for 10000 people who execute this CloudScript function 20 times per month:

(0.0128*0.000022+ 0.000001*0.22) * 10000 * 20 = 0.10032$<br>

Are my calculations correct?

What happens if I have more than 1 million executions per month? Will the price of 0.000001*0.22 change if I have more than 1 million executions per month?

What happens if the ExecutionTimeSeconds of a CloudScript function is more than 100ms? How can I calculate the cost when it is more than 100ms?

I have a question about PlayStream Events.

I often use player_executed_cloudscript events in my game and I'm not sure if the cost($6.60 per million events*) of the PlayStream events depends on the size of the PlayStream event json file.

Does it cost me more money if my PlayStream event json files are bigger? For example, my PlayStream event json files are often big because I use Logs regularly:

"Logs": [
{
 "Message": "true",
 "Level": "Info"
},
0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Kim Strasser commented ·

>> Are my calculations correct?

If you in the Pay-as-you-go, and the execution time is less than 100ms. It’s correct.

>> What happens if I have more than 1 million executions per month? Will the price of 0.000001*0.22 change if I have more than 1 million executions per month?

If you in the Pay-as-you-go, the price would be always $0.22 per million executions. If you purchase the Standard Plan, the first “1 Million executions” is free. Then the price would be $0.2 per additional million executions. For more details, please check this page -- https://playfab.com/pricing/.

>> Does it cost me more money if my PlayStream event json files are bigger?

[Edited]Yes, it does. As this section said -- https://docs.microsoft.com/en-us/gaming/playfab/features/pricing/meters/meters#example. The calculation of the count of PlayStream events depends on the average size of your events. If the average size is bigger than 1KB, PlayFab would calculate bigger count of events, it would cost you more money. The size less than 1KB would be calculated as 1KB. PlayFab would calculate count of events depends on actual count.

0 Likes 0 ·
Kim Strasser avatar image Kim Strasser Sarah Zhang commented ·

I have one more question about CloudScript. How can I calculate the CloudScript costs if the ExecutionTimeSeconds is more than 100ms? Will the 128mb change if ExecutionTimeSeconds is more than 100ms?

For example, if ExecutionTimeSeconds is 0,1403627 that equals 140,3627ms. How can I calculate the cost in this case?

0 Likes 0 ·
Show more comments
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.