# gRPC 错误：DEADLINE_EXCEEDED — 服务器过忙，无法在截止时间内响应

- **ID:** `api/grpc-deadline-exceeded-server-busy`
- **领域:** api
- **类别:** runtime_error
- **错误码:** `DEADLINE_EXCEEDED`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

gRPC 服务器由于高负载、资源争用或下游依赖缓慢，未能在客户端指定的截止时间内处理请求。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC 1.60+ | active | — | — |
| gRPC-Go 1.60+ | active | — | — |
| gRPC-Python 1.60+ | active | — | — |

## 解决方案

1. ```
   实现客户端重试，使用指数退避和抖动。gRPC-Go 示例：`grpc.WithDefaultCallOptions(grpc.MaxRetryAttempts(3), grpc.WithBackoff(grpc.DefaultBackoffConfig))`。
   ```
2. ```
   通过添加更多实例或增加资源（CPU/内存）来扩展 gRPC 服务器。监控服务器指标（例如 `grpc_server_requests_in_flight`）。
   ```
3. ```
   降低请求复杂度或实现服务器端速率限制以防止过载。示例：在服务器配置中使用 `grpc.MaxConcurrentStreams`。
   ```

## 无效尝试

- **** — If the server is overloaded, a longer deadline just delays the timeout; the request may still fail or degrade other requests. (80% 失败率)
- **** — The server is still busy; immediate retries worsen load and likely fail again. (90% 失败率)
- **** — The error is a server-side timeout, not a connection failure; network is likely fine. (60% 失败率)
