Chapter 29: Custom Serializers and Codecs
Beyond Protobuf
gRPC defaults to Protobuf but supports pluggable serialization:
- Protobuf (default):
application/grpc+proto - JSON:
application/grpc+json(useful for debugging) - FlatBuffers: zero-copy deserialization
- Custom: implement the Codec interface
When to Use Non-Protobuf
- JSON codec: debugging, interop with systems that can't use protobuf
- FlatBuffers: extreme performance (avoid deserialization entirely)
- Custom: legacy wire formats you must support
In practice, 99% of gRPC services use Protobuf. Don't change unless you have a measured reason.