# INTERNAL: grpc: 流 123 的流量控制窗口已耗尽

- **ID:** `grpc/flow-control-window-exhausted`
- **领域:** grpc
- **类别:** resource_error
- **错误码:** `EFLOWCTRL`
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

特定流的 HTTP/2 流量控制窗口已耗尽，因为接收方没有足够快地消耗数据，导致停滞或内部错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC v1.56.0 | active | — | — |
| gRPC v1.60.0 | active | — | — |
| gRPC v1.63.0 | active | — | — |

## 解决方案

1. ```
   Increase the initial flow control window size on the server: `server = grpc.server(futures.ThreadPoolExecutor(max_workers=10), options=[('grpc.initial_reconnect_backoff_ms', 1000), ('grpc.http2.min_recv_flow_control_window', 8388608)])`
   ```
2. ```
   Optimize the receiver's data consumption by batching reads or using async I/O to avoid blocking the event loop.
   ```
3. ```
   Implement backpressure at the application layer: have the client send smaller chunks or wait for acknowledgments before sending more data.
   ```

## 无效尝试

- **Restarting the client or server without changing flow control settings.** — The window exhaustion recurs under the same load pattern; restarting only provides temporary relief. (80% 失败率)
- **Disabling flow control entirely by setting `grpc.http2.lookahead_bytes` to 0.** — Flow control is a fundamental HTTP/2 mechanism; disabling it can cause memory exhaustion and connection instability. (70% 失败率)
- **Increasing the number of worker threads on the receiver side.** — While it may help consume data faster, the root cause is often slow application-level processing, not thread count. (50% 失败率)
