gRPC vs REST
Protocol Buffers vs JSON serialization, streaming modes (unary/server/client/bidirectional), HTTP/2 multiplexing, and choosing the right API style.
Overview
Overview gRPC and REST are the two dominant API paradigms in modern distributed systems, and choosing between them has significant performance, developer experience, and operational implications. Understanding both deeply is expected at senior engineering levels at Google, Amazon, and Meta.
REST (Representational State Transfer) is an architectural style using HTTP/1.1 with JSON. It relies on standard HTTP verbs (GET, POST, PUT, DELETE, PATCH), stateless request-response patterns, and human-readable JSON payloads. REST's simplicity, browser compatibility, and universal tooling have made it the default for public-facing APIs.
gRPC is a high-performance RPC framework developed by Google, built on HTTP/2 and Protocol Buffers (protobuf). It uses a schema-first approach where services and messages are defined in .proto files, and code is generated for both client and server in dozens of languages. gRPC supports four communication patterns: unary (single request-response, like REST), server streaming (one request, multiple responses), client streaming (multiple requests, one response), and bidirectional streaming.
The performance difference is substantial in high-throughput scenarios. Protobuf serialization is 3-10x faster than JSON and produces payloads 2-5x smaller. HTTP/2 multiplexing eliminates head-of-line blocking and allows hundreds of concurrent requests over a single TCP connection. gRPC also supports flow control, header compression (HPACK), and built-in deadline propagation.
In production systems, gRPC is used for internal service-to-service communication (Google's internal Stubby protocol inspired gRPC), while REST or GraphQL is typically used for external APIs. Kubernetes uses gRPC for its API server communication with kubelets. Envoy proxy uses gRPC for its xDS configuration protocol.
Key concepts
- Protocol Buffers (protobuf)
- HTTP/2 Multiplexing
- gRPC Streaming Modes
- Deadlines and Cancellation
- gRPC Transcoding
Interview questions
- When would you choose gRPC over REST for a new microservice, and what operational considerations does that choice introduce?
- Explain how gRPC bidirectional streaming works and give a real-world use case where it is the right choice.
Sign up free to read the full topic
More Networking topics
Start free on Cariara · Coding problems · System design studio