英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论