Limits

Cloud Code modules have limits for the amount of data that you can process.

Cloud Code API

  • The Cloud Code Client API service limits each player to 12,000 requests per minute.
  • The Cloud Code Admin API service limits each Service Account to 120 requests per minute.
  • The Admin API has lower rate limits, so don't call the Admin API on a per-player basis.

Cloud Code C# modules

  • The .ccm file that contains your module can't exceed 10 MB in size.
  • The combined size of all .ccm files in your project can't exceed 128 Mb in size.
  • The combined size of the response body (the module's output) when you execute a module can't exceed 2 MiB.
  • You can't have more than 20 modules across all your environments in your project.
  • A module function execution time cannot exceed 15 seconds. If a function does exceed this time limit, the process is killed.
  • A module can have a maximum of 10 tags, and the maximum allowed characters per tag key and tag value is 128.
  • If a module has not received any traffic in the last 15 minutes, you may experience a cold start latency. Any subsequent calls to the module are faster.
  • async void patterns cause errors. Always return a Task or Task<T>. Refer to the official Microsoft documentation for best practices in asynchronous programming.
  • Cloud Code doesn't support static methods for Cloud Code functions.

Module persistence between invocations

There is no guarantee that the module state persists between invocations. The module may reload on a different worker, so you can't always rely on shared state across module function invocations. However, while the module remains loaded, static variables and singleton dependencies are shared across invocations.

You can use this behavior to your advantage and cache data in static variables or singleton dependencies to reduce the amount of data you need to fetch from external services. Don't use this module behavior to persist data, especially data that you require to be consistent for all players.

Dependency injection

  • Don't rely on shared state across module function invocations because the API call is not guaranteed to land on the same worker each time when there are multiple workers.
  • If Cloud Code a worker exceeds the 256 MB memory limit, the worker eventually crashes.
  • The ICloudCodeSetup configuration should only be implemented by a single class in one module.

Push messages

  • Messages sent over the WebSocket connection have a limit of 10 KB.

UGS CLI and Editor deployment

  • The UGS CLI and the Deployment window cannot deploy modules that contain multiple modules in the same project.
  • The UGS CLI and the Deployment window do not support module tags and ignore them.

Editor bindings

  • Generated bindings do not differentiate between required parameters and optional parameters.
  • Tuples are not supported as parameters or the return value.

Cloud Code integration with other Unity services

  • All Unity services have a per-player rate limit to prevent API overuse. The Cloud Code rate limit is shared between the game and the server code. For example, if you use Economy from both Cloud Code and the game, you may receive an unexpected rate limit error. It's important to account for both types of use when you debug these errors.
  • Modules can only access other UGS resources that you deploy to the same environment that you save the module in. Modules can't access services in any other environment.

For more information on how to integrate with Cloud Code, refer to the Integrate with other Unity services page.