What Is gRPC? RPC, Protobuf and HTTP/2 Explained
On this page
The problem gRPC solves: hand-written clients
Inside a system of 30 services, each team writes HTTP clients for the services it calls: building URLs, serializing JSON, parsing responses, guessing which fields are optional. Every service change risks breaking a caller nobody remembered. And JSON is verbose: field names repeat in every message, numbers travel as text.
RPC stands for remote procedure call: calling a function that runs on another machine as if it were a local one. gRPC, open-sourced by Google in 2015 and now a CNCF project, takes a different approach: define the API once in a schema, generate typed clients and servers in every language, and send compact binary messages over HTTP/2.
How gRPC works: Protocol Buffers, generated code and HTTP/2
1. A contract in Protocol Buffers. The service and its messages are defined in a .proto file (Day 2):
service OrderService {
rpc GetOrder(GetOrderRequest) returns (GetOrderResponse);
rpc WatchOrder(WatchOrderRequest) returns (stream WatchOrderResponse);
}2. Generated code. protoc or buf turns that into a client with a GetOrder method and a server interface to implement (Day 4). Calling another service looks like calling a function:
resp, err := client.GetOrder(ctx, &shopv1.GetOrderRequest{OrderId: "ord_42"})3. Binary messages over HTTP/2. Messages are encoded with Protocol Buffers' compact binary format (Day 11) and sent as HTTP/2 streams, so many calls share one connection and both sides can stream. HTTP/1.1 is like a single-lane road where each car (request) waits for the one in front to finish its trip; HTTP/2 multiplexes, turning one connection into many lanes, so a slow call doesn't block the others and there's no need to open a new connection per call.
Protobuf vs JSON size
A message with a name, an age and a flag, encoded both ways (tested with protoc in Day 11):
Protobuf: 0a 02 41 6c 10 96 01 80 01 01 10 bytes
JSON: {"name":"Al","age":150,"vip":true} 34 bytesField names never travel in protobuf; small numbers ("field 1", "field 2") identify fields instead. Encoding and decoding are also faster than parsing JSON text.
gRPC features: streaming, deadlines, interceptors
- Four call types: unary request and response, server streaming, client streaming and bidirectional streaming (Days 7 to 10).
- Deadlines that propagate across services (Day 15), cancellation, and standard status codes (Day 14).
- Interceptors for logging, auth and metrics (Day 16).
- Code generation for Go, Java, Kotlin, C#, Python, C++, Node, Swift, Dart, Rust and more.
- Schema evolution rules that let services upgrade independently (Day 12).
The costs of using gRPC
- Not human-readable: you can't inspect traffic with
curl; you need tools likegrpcurl(Day 20). - Browsers can't call gRPC directly; they need gRPC-Web or a gateway (Day 19).
- Load balancing is different: long-lived HTTP/2 connections defeat connection-level load balancers (Day 18).
- A build step: generated code must stay in sync with the schema.
That's why gRPC is most common between services, with REST or GraphQL at the public edge (Day 5).
Check yourself
Generated client code from the .proto contract exposes each RPC as a typed method, such as client.GetOrder(ctx, req). The stub handles serialization, HTTP/2 transport and status decoding, so calling code looks like a normal function call, though it can still fail like any network call.
Field names are replaced by small numeric tags, numbers use compact variable-length binary encodings instead of text, and there's no whitespace or quoting. Messages are often several times smaller than the equivalent JSON and faster to parse.
Browsers can't speak native gRPC, and binary traffic is harder for third parties to inspect, while internal services benefit most from typed contracts and efficiency.
Many concurrent calls multiplexed over one connection, binary framing, header compression and streams in both directions, which make streaming RPCs possible.
Binary payloads are harder to inspect, browsers need a proxy or Connect, load balancing needs care, and teams must manage .proto files and code generation.