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
PAYLOAD SIZE β same user object
JSON ββββββββββββββββββββββββββββββββ 312 bytes
JSON+gzip ββββββββββββββ 138 bytes
Protobuf βββββββ 74 bytes
βββ field names are replaced by numeric tagsCONTRACT-FIRST β one .proto generates both sides
ββββββββββββββββ
β user.proto β
ββββββββ¬ββββββββ
protoc β protoc
βββββββββββββ΄βββββββββββββ
βΌ βΌ
ββββββββββββ ββββββββββββ
β TS clientβ β Go serverβ
β stub β β stub β
ββββββ¬ββββββ βββββββ²βββββ
β binary over HTTP/2 β
ββββββββββββββββββββββββββ
compile-time type safety on both endsFOUR CALL SHAPES
Unary client βββΊ server βββΊ one in, one out
Server stream client βββΊ server βββΊ one in, many out
Client stream client βββΊ server βββΊ many in, one out
Bidirectional client βββΊ server βββΊ both stream freelyHow 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.