Cloud Run 服务部署失败,错误信息为‘超出资源配额:projects/my-project/regions/us-central1/quotas/max-instances。限制:100,使用量:100’
Cloud Run service deployment fails with 'Quota exceeded for resource: 'projects/my-project/regions/us-central1/quotas/max-instances'. Limit: 100, Usage: 100'
ID: policy/cloud-run-max-instances-quota-exceeded
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Cloud Run API v1 | active | — | — | — |
| gcloud CLI 400.0.0+ | active | — | — | — |
| Google Cloud Console as of 2024 | active | — | — | — |
根因分析
Cloud Run 服务的 max-instances 设置(或该区域所有服务的 max-instances 总和)超过了该区域的最大实例配额,默认通常为 100。
English
The Cloud Run service's max-instances setting (or the sum of all services' max-instances in the region) exceeds the regional quota for max instances, which is typically 100 by default.
官方文档
https://cloud.google.com/run/quotas解决方案
-
使用 `gcloud run services list --region=us-central1` 识别该区域的所有 Cloud Run 服务,求和它们的 max-instances 值,然后减少一个或多个服务的 max-instances 以使总和低于配额(例如 100),然后重新部署。
-
通过 Google Cloud 控制台请求配额增加:转到 IAM 和管理 > 配额,找到 Cloud Run 的‘每个区域的最大实例数’,请求增加(例如增加到 200)。这可能需要 1-2 个工作日。
-
仅当服务是 CPU 节流且可以处理冷启动时,才将 max-instances 设置为 0(这意味着无限制),但请注意,这仅在总使用量低于配额时才绕过配额检查。如果总使用量已达到限制,这仍然会失败。
无效尝试
常见但无效的做法:
-
60% 失败
The quota error is about the total sum of max-instances across all services in the region, not just one service. Reducing one service may not bring the total under the limit if other services have high values.
-
80% 失败
The quota is persistent and region-level. Deleting and recreating does not change the usage count until the service is fully removed, and the new deployment will still fail if the quota is exceeded.
-
90% 失败
This will immediately exceed the quota even more, causing the same error. The quota limit is enforced at deployment time.