Flow Control

Explains what flow control is and how you can manually control it.

Flow Control

Explains what flow control is and how you can manually control it.

Overview

Flow control is a mechanism to ensure that a receiver of messages does not get overwhelmed by a fast sender. Flow control prevents data loss, improves performance and increases reliability. It applies to streaming RPCs and is not relevant for unary RPCs. By default, gRPC handles the interactions with flow control for you, though some languages allow you to take override the default behavior and take explicit control.

gRPC utilizes the underlying transport to detect when it is safe to send more data. As data is read on the receiving side, an acknowledgement is returned to the sender letting it know that the receiver has more capacity.

As needed, the gRPC framework will wait before returning from a write call. In gRPC, when a value is written to a stream, that does not mean that it has gone out over the network. Rather, that it has been passed to the framework which will now take care of the nitty gritty details of buffering it and sending it to the OS on its way over the network.

Sender ApplicationSender gRPC FrameworkReceiver gRPC FrameworkReceiver ApplicationStream WriteWaitalt[sending toofast]Write call returnsSend Msgalt[allowed to send]Request messageRequest can be done eitherafter or before message arrivesProvide messageSend Ack w/ msg sizeSend Next Msgopt[waiting messages]Sender ApplicationSender gRPC FrameworkReceiver gRPC FrameworkReceiver Application

Language Support

LanguageExample
JavaJava Example