Skip to content

Commit 65e5ed1

Browse files
authored
Add gRPC MaxConcurrentStreams limit and flag (#679)
Plausibly this should be in weaveworks/common/server, but I wanted to try it out more locally first.
1 parent 304e21a commit 65e5ed1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmd/ingester/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,22 @@ func main() {
3232
storageConfig storage.Config
3333
ingesterConfig ingester.Config
3434
logLevel util.LogLevel
35+
maxStreams uint
3536
)
3637
// Ingester needs to know our gRPC listen port.
3738
ingesterConfig.ListenPort = &serverConfig.GRPCListenPort
3839
util.RegisterFlags(&serverConfig, &chunkStoreConfig, &storageConfig,
3940
&schemaConfig, &ingesterConfig, &logLevel)
41+
flag.UintVar(&maxStreams, "ingester.max-concurrent-streams", 1000, "Limit on the number of concurrent streams for gRPC calls (0 = unlimited)")
4042
flag.Parse()
4143
schemaConfig.MaxChunkAge = ingesterConfig.MaxChunkAge
4244

4345
util.InitLogger(logLevel.AllowedLevel)
4446

47+
if maxStreams > 0 {
48+
serverConfig.GRPCOptions = append(serverConfig.GRPCOptions, grpc.MaxConcurrentStreams(uint32(maxStreams)))
49+
}
50+
4551
server, err := server.New(serverConfig)
4652
if err != nil {
4753
level.Error(util.Logger).Log("msg", "error initializing server", "err", err)

0 commit comments

Comments
 (0)