This article addresses an intermittent response code from Cloud Code that most often occurs during development, or in games with very few players, and disappears on a retry.
Symptoms:
When invoking a Cloud Code Module function regardless of whether it's by the API or the SDK, you may receive a 503 "Service Unavailable" error the first time you invoke a module after some time.
This usually only occurs whilst a game is in development, or has a very low number of players; games that are in production do not tend to have this issue.
Cause:
Cloud Code executors go into shutdown after there is no activity for 15 minutes. This serves as a cost saving mechanism and allows us to avoid standing charges for using the service.
Sometimes it takes longer for the executor to start up than the API allows for in a request. In these circumstances, the the API returns a 503 error if it's unable to locate a ready executor.
Solution:
At the time of writing, we are working on improvements to the Cloud Code infrastructure to address this issue using the same techniques that allow Cloud Code Scripts to execute even whilst there is no dedicated executor available. Once that is implemented, the issue will disappear.
In the meantime, having a retry mechanism when a 503 is returned should be sufficient.