Rate Control and Back Pressure in gRPC in Cpp

huangapple go评论47阅读模式
英文:

Rate Control and Back Pressure in gRPC in Cpp

问题

我如何在gRPC的cpp中实现速率控制和背压?

我查阅了文档,发现有一个叫做流量控制限制的东西,可以帮助标识窗口大小是否已满,但我找不到如何设置它。

英文:

How can I implement rate control and back pressure in gRPC in cpp?

I went through the documentation and found that there's something called a flow control limit that can help in signifying if the window size is full but I cannot find how to set that.

答案1

得分: 1

gRPC基于HTTP/2,因此使用HTTP/2流控制。在C++中,流控制在API中是隐式的:当你从流中执行Read()操作时,它会自动释放由挂起的读取操作占用的流控制窗口量。所以,要施加背压,你只需要停止从流中读取;当缓冲区填满时,客户端将不会再发送更多数据。

通常情况下,你不应该直接调整可用的流控制窗口的数量,这样做是不被推荐的,但如果你确实需要,你可以使用GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES通道参数来进行调整。

英文:

gRPC is based on HTTP/2 and therefore uses HTTP/2 flow control. In C++, the flow control is implicit in the API: when you do a Read() from a stream, it automatically releases the amount of flow control window that was held by that pending read. So all you have to do to apply back-pressure is to stop reading from the stream; when the buffers fill up, the client will not send any more data.

You generally should not need to tune the amount of flow control window available directly, and doing so is discouraged, but if you really need to, you can use the GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES channel arg to do it.

huangapple
  • 本文由 发表于 2023年5月17日 14:35:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76269146.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定