What gRPC is
gRPC is a remote procedure call framework that uses Protocol Buffers for the message schema and HTTP two for transport. You define services and messages in a proto file, then generate typed client and server stubs.
Why it is fast
- Binary encoding: protobuf packs fields by number into a compact binary form, far smaller than JSON text.
- HTTP two: one connection multiplexes many calls and supports streaming in both directions.
- Generated stubs: the proto file is the contract, so client and server share types with no hand written parsing.
Streaming modes
- Unary: one request, one response.
- Server streaming: one request, a stream of responses.
- Client streaming: a stream of requests, one response.
- Bidirectional: both sides stream at once.
Tradeoffs
- Great for service to service traffic where both sides are controlled.
- Awkward in browsers since native HTTP two access is limited, so a proxy or gRPC web layer is needed.
- Binary is not human readable, so debugging needs tooling.
Key idea
gRPC pairs a compact protobuf schema with multiplexed streaming HTTP two to give fast strongly typed internal calls, at the cost of browser friendliness and readable payloads.