Script cost

Cloud Code has a free tier so that you can start developing and launch with it for free. You only start paying once your organization scales beyond the free tier or any applicable credit allowance.

You can find more details and the pricing FAQ on the UGS product pricing overview page.

Cost calculations

Costs are calculated over three categories:

CategoryDescription
InvocationsInvocations count the successful Cloud Code script execution requests within your organization. A successful execution covers any request that returns any response from the script with an HTTP 200 status code.
Compute hoursCompute hours are the seconds executing Cloud Code scripts within your organization. Executions can also include additional warm-up time.
EgressEgress measures the size of responses (in GiB) from successful Cloud Code script executions within your organization. A successful execution covers any request that returns any response from the script with an HTTP 200 status code.

Cost saving tips

Follow the tips below to reduce your cost using Cloud Code.

  • Ensure script responses only contain data that you use. Unused data contained in script responses still contributes to your egress costs.
  • Ensure your Cloud Code scripts complete within the allotted 15 second timeout. An accidental while(true) loop can generate unexpected costs.
  • Consider you can batch executions together. For example, Cloud Code script ScriptExampleB may depend on the response from ScriptExampleA, calling these individually could cost double the amount compared to combining the logic of both into one script call.

Command batching

Command batching is a concept where each game action is a command that you can collect into a queue and send to the server in batches to process. For more information, refer to the Command batching page.

For example, consider a game that distributes rewards after every action by calling Cloud Save to distribute player XP and Economy to distribute coins. The player completes the following three actions:

  • The first action results in 100 XP and 10 coins.
  • The second action results in 50 XP and 5 coins.
  • The third action results in 200 XP and 30 coins.

These three actions result in a minimum of six calls to various Unity services (in this case, Cloud Save and Economy) if you execute them independently. However, you can store all three of these actions as batch commands and process them through a single Cloud Code script request. This means that your game only has to make two Unity services calls: one to Cloud Save to increase XP by 350, and one to Economy to add 45 coins.