open-feature / flagd

A feature flag daemon with a Unix philosophy
https://openfeature.dev
Apache License 2.0
510 stars 61 forks source link

[FEATURE] Allow user to set max message size limit on grpc source #1357

Closed pradeepbbl closed 2 months ago

pradeepbbl commented 2 months ago

Requirements

Hi,

As discussed in the community slack channel, currently we are using the default MaxMsgSize 4MB in gRPC sync source in most cases it is large enough but in bigger installation it could be issue e.g.

2024-07-10T14:35:17.327Z    warn    grpc/grpc_sync.go:123   error with stream listener: error receiving payload from stream: rpc error: code = ResourceExhausted desc = grpc: received message larger than max (5727401 vs. 4194304)    {"component": "sync", "sync": "grpc"}

This task is to allow users to set MaxMsgSize limit part of source configuration.

-Thanks

Kavindu-Dodan commented 2 months ago

I think the root cause here is not the flag payload size but a data corruption that was reported in grpc java. Flagd Java provider v0.8.4 [1] fixes this as we updated the dependency causing this [2].

But let me know if you are seeing this non-Java provider. Then that's an interesting situation.

Update - Assuming the usage here is flagd connecting to a Java-based gRPC stream, the same root cause could have created this issue. 4MB should allow at least 8k ~ 10K flagd flags to be transmitted without altering the max message size.

[1] - https://github.com/open-feature/java-sdk-contrib/releases/tag/dev.openfeature.contrib.providers.flagd-v0.8.4 [2] - https://github.com/open-feature/java-sdk-contrib/pull/849#issuecomment-2207398472

Kavindu-Dodan commented 2 months ago

@pradeepbbl thank you for the contribution. I have merged your solution. This will be included with our next release [1]

[1] - https://github.com/open-feature/flagd/pull/1356