The Hypothesis
gRPC uses Protocol Buffers (binary) and HTTP/2 multiplexing. REST uses JSON and HTTP/1.1. Theory says gRPC should be faster. But by how much, and does it matter?
Benchmark Setup
We compared:
- REST endpoint: Express.js + JSON, HTTP/1.1
- gRPC endpoint: Node.js gRPC server, HTTP/2
- Payloads: 1KB, 10KB, 1MB
- Concurrency: 1, 10, 100 concurrent clients
- Load duration: 30 seconds each
Results
| Payload | REST P99 | gRPC P99 | Speedup |
|---|---|---|---|
| 1KB | 45ms | 12ms | 3.75x |
| 10KB | 120ms | 28ms | 4.3x |
| 1MB | 2.1s | 380ms | 5.5x |
Why gRPC Wins
- Binary serialization: Protocol Buffers is ~10x smaller than JSON for structured data
- Multiplexing: HTTP/2 sends multiple requests on one TCP connection
- No text parsing: Protobuf decoder is faster than JSON.parse()
- Compression: gRPC supports transparent compression (gzip, etc.)
The Gotchas
Complexity
REST: curl works. gRPC: need grpcurl or a gRPC client library.
Ecosystem
Need to maintain .proto files, regenerate clients, manage versioning.
Debugging
REST: browser console, logs are readable. gRPC: binary format, need specialized tools.
Recommendation
Use gRPC for:
- High-throughput internal services (>100 RPS)
- Large payloads (>10KB)
- Low-latency requirements (microservices within data center)
Use REST for:
- Simple CRUD APIs
- Browser/third-party integrations
- Prototyping and debugging
- Team unfamiliar with gRPC