gRPC
gRPC is Google’s open-source RPC framework. It uses HTTP/2 as the transport, Protocol Buffers for interface definition and serialization, and supports four streaming models.
Why HTTP/2?
HTTP/2 multiplexing lets multiple RPC calls share one TCP connection without head-of-line blocking at the HTTP layer. gRPC maps each RPC to one or more HTTP/2 streams.
Streaming models
| Model | Description |
|---|---|
| Unary | Single request, single response — closest to classic REST. |
| Server streaming | Client sends one message; server streams many responses. |
| Client streaming | Client streams many messages; server returns one response. |
| Bidirectional | Both sides stream independently — chat-like protocols. |
Metadata
gRPC uses HTTP/2 headers for metadata (deadlines, auth tokens, tracing IDs). Deadlines propagate as grpc-timeout and should always be set client-side.
gRPC-Web
Browsers cannot speak native gRPC (requires trailers and binary framing). gRPC-Web proxies translate between browsers and gRPC servers, typically over HTTP/1.1 or HTTP/2.