grpc resource_error ai_generated true

INTERNAL: grpc: max concurrent streams exceeded on server

ID: grpc/grpc-max-concurrent-streams-exceeded

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
1Evidence
2023-11-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
grpc-go 1.61.0 active
grpc-java 1.60.0 active
envoy 1.27.0 active
nginx 1.25.0 active

Root Cause

Server's HTTP/2 max concurrent streams limit (default 100) is reached, and new streams are rejected.

generic

中文

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

Official Documentation

https://grpc.io/docs/guides/performance/#flow-control

Workarounds

  1. 85% success 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.
    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. 75% success 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.
    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.

中文步骤

  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.

Dead Ends

Common approaches that don't work:

  1. 85% fail

    The limit is on the server side per connection; client pool size doesn't affect server stream limits.

  2. 90% fail

    Stream count is unrelated to message size; this does not free up stream slots.