# INTERNAL: gRPC: 服务器上最大并发流超出：128 个活动流，限制 100

- **ID:** `grpc/max-concurrent-streams-exceeded`
- **领域:** grpc
- **类别:** resource_error
- **错误码:** `GRPC_MAX_CONCURRENT_STREAMS`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

gRPC 服务器已达到配置的最大并发流数（许多实现中默认 100），由于资源耗尽而拒绝创建新流。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC-go v1.58.0 | active | — | — |
| gRPC-java v1.57.0 | active | — | — |
| C-core v1.58.0 | active | — | — |

## 解决方案

1. ```
   Increase the max concurrent streams limit in server configuration. In Go: server := grpc.NewServer(grpc.MaxConcurrentStreams(200)). In Java: NettyServerBuilder.forPort(port).maxConcurrentCallsPerConnection(200).
   ```
2. ```
   Enable client-side connection multiplexing by setting grpc.initial_conn_window_size to a higher value (e.g., 1MB) and use a load balancer to distribute streams across multiple server connections.
   ```
3. ```
   Implement stream pooling or batching on the client: instead of opening one stream per request, use client-side streaming to send multiple messages over a single stream, reducing the total stream count.
   ```

## 无效尝试

- **** — Simply increasing the limit without addressing slow consumers or long-lived streams can lead to memory exhaustion and OOM kills. (80% 失败率)
- **** — Adding more server instances without adjusting client connection pooling may cause clients to still hit per-connection limits on each instance. (75% 失败率)
