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.
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.