# 内部错误: grpc: 服务器上超过最大并发流数

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

## 根因

服务器的 HTTP/2 最大并发流限制（默认 100）已达到，新流被拒绝。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| grpc-go 1.61.0 | active | — | — |
| grpc-java 1.60.0 | active | — | — |
| envoy 1.27.0 | active | — | — |
| nginx 1.25.0 | active | — | — |

## 解决方案

1. ```
   Increase the server's max concurrent streams limit. In gRPC-Go, use:
  import "google.golang.org/grpc"
  s := grpc.NewServer(grpc.MaxConcurrentStreams(200))
  Or set environment variable GRPC_GO_MAX_CONCURRENT_STREAMS=200 before starting the server.
   ```
2. ```
   Reduce the number of long-lived streams by batching requests or using unary RPCs instead of streaming. Alternatively, add more server instances behind a load balancer to distribute streams.
   ```

## 无效尝试

- **** — The limit is on the server side per connection; client pool size doesn't affect server stream limits. (85% 失败率)
- **** — Stream count is unrelated to message size; this does not free up stream slots. (90% 失败率)
