REST vs gRPC
On this page
What gRPC is
gRPC is a high-performance RPC framework built on HTTP/2. It uses Protocol Buffers (binary serialization) and strongly defined service contracts.
Protocol differences
- REST: HTTP + JSON (text-based).
- gRPC: HTTP/2 + Protobuf (binary).
Performance and latency
Binary serialization and HTTP/2 multiplexing make gRPC efficient for low-latency, high-throughput internal communication.
Streaming
- REST: usually request-response model.
- gRPC: supports client streaming, server streaming, and bidirectional streaming natively.
Contracts
gRPC services are defined in .proto files. These definitions generate strongly-typed client and server code in multiple languages.
Example (conceptual)
service UserService {
rpc GetUser (UserRequest) returns (UserResponse);
}
When gRPC wins
- Internal microservice communication.
- Low latency requirements.
- Strong typing across multiple backend services.
- High-frequency data streaming.
When REST is simpler
- Public APIs consumed by browsers.
- Simple CRUD services.
- CDN caching and easy debugging with curl.
Operational considerations
- gRPC requires HTTP/2 support and compatible tooling.
- Debugging raw gRPC traffic is less human-friendly than JSON.
Checklist
- Need streaming and low latency? Consider gRPC.
- Need public, browser-friendly APIs? REST is usually simpler.
- Do you need strict contracts and code generation? gRPC helps.