# Cloud Run 服务部署失败，错误信息为‘超出资源配额：projects/my-project/regions/us-central1/quotas/max-instances。限制：100，使用量：100’

- **ID:** `policy/cloud-run-max-instances-quota-exceeded`
- **领域:** policy
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

Cloud Run 服务的 max-instances 设置（或该区域所有服务的 max-instances 总和）超过了该区域的最大实例配额，默认通常为 100。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Cloud Run API v1 | active | — | — |
| gcloud CLI 400.0.0+ | active | — | — |
| Google Cloud Console as of 2024 | active | — | — |

## 解决方案

1. ```
   使用 `gcloud run services list --region=us-central1` 识别该区域的所有 Cloud Run 服务，求和它们的 max-instances 值，然后减少一个或多个服务的 max-instances 以使总和低于配额（例如 100），然后重新部署。
   ```
2. ```
   通过 Google Cloud 控制台请求配额增加：转到 IAM 和管理 > 配额，找到 Cloud Run 的‘每个区域的最大实例数’，请求增加（例如增加到 200）。这可能需要 1-2 个工作日。
   ```
3. ```
   仅当服务是 CPU 节流且可以处理冷启动时，才将 max-instances 设置为 0（这意味着无限制），但请注意，这仅在总使用量低于配额时才绕过配额检查。如果总使用量已达到限制，这仍然会失败。
   ```

## 无效尝试

- **** — 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. (60% 失败率)
- **** — 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. (80% 失败率)
- **** — This will immediately exceed the quota even more, causing the same error. The quota limit is enforced at deployment time. (90% 失败率)
