Skip to main content
REST vs GraphQL vs gRPClesson 3 of 4 · 3 min read

gRPC

When both ends are yours

gRPC is what an API call looks like when both ends are your own code and you care what each call costs.

Describe your services and messages in one file, run the generator, and get typed client and server code in a dozen languages. Calling a remote service reads like calling a local function, and your compiler catches a misspelled field before a single request leaves the building.

Send it over Protocol Buffers, a binary format roughly five times smaller than the same data as JSON. It is much cheaper to read too, because there are no field names or quotes to scan, only tags and lengths.

At ten requests a second nobody notices that. At fifty thousand internal calls a second, the processor time your fleet stops spending on encoding shows up as a line on the cloud bill.

Run it over HTTP/2, which carries many calls at once down one connection instead of doing a fresh connection dance per request.

Get four shapes of call out of that. Plain request and response. Server streaming, where you subscribe to a feed of updates. Client streaming, where you upload a stream of chunks. And both directions at once, each side sending independently over one call. Deadlines and cancellation travel down the chain natively, which matters when A calls B calls C and your user gave up ten seconds ago.

The costs

Weigh the costs, because they are concrete. Browsers cannot speak gRPC directly, so a browser client needs a translating proxy in front.

Debug without curl, since the payloads are not human-readable and you need the schema in hand and a different tool. And treat that schema file as a shared contract. Field numbers can never be reused, and removing a field somebody still reads is a coordination problem, not a code review comment.

the shape of it
Client stubOne HTTP/2 linkmany calls at onceServer stubStreaming both waysRequest, response1. typed call2. binary frames3a. server pushes3b. one answer
step 1 of 3
One connection carries many typed calls, in either direction, as binary frames.

Worked example

A logistics company's route optimization service receives location pings from its driver fleet, 30,000 JSON POSTs per second at peak, each about 900 bytes. The ingestion tier runs 14 instances mostly doing JSON parsing. Tomas leads a migration to gRPC: the ping becomes a 140-byte protobuf message, and drivers' phones hold one client-streaming call open instead of a fresh HTTPS request per ping, eliminating per-request TLS and header overhead. After the rollout, ingestion handles the same load on 5 instances, latency at p99, the number the slowest one request in a hundred comes in under, drops from 180 ms to 40 ms, and cross-region bandwidth spend falls by roughly 60 percent. The one casualty is the ops dashboard that used to tail readable JSON logs; the team adds grpcurl runbooks and a debug endpoint that renders recent pings as text.