Beyond one request one response
gRPC runs on HTTP2, whose multiplexed streams let a single call carry a sequence of messages rather than just one. This unlocks four call shapes.
The four shapes
- Unary is the familiar one request and one response.
- Server streaming sends one request and receives many responses, useful for feeds.
- Client streaming sends many requests and gets one response, useful for uploads.
- Bidirectional streaming lets both sides send sequences independently over the same call.
How it works underneath
Each call is an HTTP2 stream, and messages are length prefixed frames within it. Because HTTP2 multiplexes many streams over one connection, several streaming calls coexist without blocking each other at the application layer. Flow control keeps a fast sender from overwhelming a slow receiver, and either side can signal the end of its message stream. Bidirectional streaming is powerful but requires careful handling of ordering and backpressure.
Key idea
gRPC uses HTTP2 streams to offer unary, server, client, and bidirectional streaming over a single multiplexed connection.