Part I — The Pipes · Lesson 1.7
gRPC
In one lineBinary contracts over HTTP/2 — call a remote function like a local one, in a fraction of the bytes.
Where you've seen itNot in your browser tab, but one hop behind it — checkout → inventory → pricing, thousands of calls per second.
Diagram
How it works
- Define messages and services in a
.protofile — this is the contract. protocgenerates typed client and server stubs in every language you use.- Calls travel as binary Protobuf frames over HTTP/2, multiplexed on one connection.
- Streaming is native, in either or both directions.
Trade-offs
| Use when | Avoid when |
|---|---|
| Service-to-service, high volume | Public API for unknown clients |
| Polyglot teams needing one contract | You want browsable URLs and curl |
| Streaming is a first-class need | No time to run a proxy |
The browser catch: browsers can't speak raw gRPC — no access to HTTP/2 frames from JS. You need gRPC-Web plus an Envoy proxy, and that path loses client-streaming. For most frontends this is exactly why the browser talks REST or GraphQL to a BFF, and the BFF talks gRPC onward.
Interview angle
"Why don't we just use gRPC from the browser?"
- The Fetch API gives no control over HTTP/2 framing, so raw gRPC is impossible.
- gRPC-Web works but needs a translating proxy and drops client-side streaming.
- The usual shape: browser → BFF (REST/GraphQL) → services (gRPC).
Recap
- Contract-first, binary, HTTP/2, streaming built in.
- ~4× smaller payloads and generated types on both ends.
- Lives behind your BFF, not in the browser.