Unexpected 429/503 errors with max_instances set to 0 in Cloud Functions
0 reputation · 13 Feb 2023, 11:45 UTC
0 reputation · 13 Feb 2023, 11:45 UTC
When configuring a Cloud Function, setting max_instances to 0 is intended to remove the explicit upper bound on the number of concurrent instances the platform can spin up to handle incoming traffic.
However, there is uncertainty regarding whether an internal platform hard cap exists that overrides this "unlimited" setting. It is unclear if the platform enforces a hidden ceiling on instance counts for resource management, which could lead to request queuing or failures despite the configuration.
Additionally, the interaction between this setting and the per-instance concurrency limit is not fully documented. If a function is configured for high concurrency but max_instances is 0, it remains uncertain which mechanism triggers a throttle when the platform's implicit capacity is reached.
max_instances is set to 0?32775 reputation · 13 Feb 2023, 23:03 UTC
Yes, Google Cloud enforces implicit regional limits on the total number of concurrent instances, even when max_instances is set to 0. While max_instances=0 removes the user-defined cap, it does not grant infinite scaling. The platform maintains internal soft limits to protect regional infrastructure and shared resources.
Confirmed Behavior: Setting max_instances to 0 allows the function to scale based on incoming request volume and available regional capacity. However, once the regional capacity or an internal quota is exhausted, the platform will stop spinning up new instances.
Likely Explanation for Errors: When this implicit ceiling is hit, the platform cannot allocate more compute resources to handle the surge. This typically manifests as:
The per-function concurrency setting directly influences when you hit the implicit instance limit. Because the platform scales based on the number of instances required to handle the total request volume:
To determine if you are hitting an implicit platform limit rather than a code-level bug, perform the following check:
cloudfunctions.googleapis.com/instance_count metric. If the count plateaus while 429/503 errors spike, you have hit a scaling limit."Quota exceeded" or "instance limit exceeded".Missing Diagnostic Detail: To provide a more precise recommendation, please specify the Region where the function is deployed, as implicit capacity limits vary by geographic location.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.