# gRPC 错误：RESOURCE_EXHAUSTED：超出速率限制

- **ID:** `api/grpc-resource-exhausted-rate-limit`
- **领域:** api
- **类别:** resource_error
- **错误码:** `RESOURCE_EXHAUSTED`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

gRPC 服务器因客户端超出配置的速率限制而拒绝请求，通常由于激进的重试或高并发导致。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC 1.62.0 | active | — | — |
| Envoy 1.29.0 | active | — | — |
| Istio 1.20.0 | active | — | — |
| gRPC-Go 1.62.0 | active | — | — |

## 解决方案

1. ```
   Implement exponential backoff with jitter in the gRPC client. Example in Go: `backoff := grpc.WithBackoffMaxDelay(5 * time.Second); conn, err := grpc.Dial(target, backoff)`.
   ```
2. ```
   Reduce concurrency by limiting the number of in-flight gRPC streams using a semaphore or connection pool. For example, use a channel-based worker pool in Go.
   ```
3. ```
   Contact the API provider to request a higher rate limit or check the Retry-After header in the gRPC trailing metadata for a suggested wait time.
   ```

## 无效尝试

- **** — Without exponential backoff, retries are sent immediately, consuming more quota and causing cascading failures. (80% 失败率)
- **** — Removing rate limits exposes the server to abuse and performance degradation. (90% 失败率)
- **** — Rate limits are often enforced at the service level regardless of protocol; REST endpoints may have similar or stricter limits. (60% 失败率)
