Beyond Protobuf
Protobuf is not the only compact format. Two common alternatives are MessagePack and Avro, and they differ mainly in how they handle schemas.
MessagePack
MessagePack is often described as binary JSON.
- It encodes the same data model as JSON, just in fewer bytes.
- It is schemaless, so each message carries its own field names.
- It is easy to adopt as a drop in for JSON where size matters.
The cost of carrying names is larger messages than a numbered format like protobuf.
Avro
Avro takes the opposite stance with a strong schema.
- Data is written with no field tags or names inside the payload.
- The reader needs a schema, which is matched against the writer schema.
- Schemas are often distributed through a schema registry.
Because both writer and reader schemas are known, Avro supports rich evolution rules. The trade off is that you must manage and version schemas carefully, since a message alone cannot be decoded without one.
Key idea
MessagePack is a schemaless binary JSON that carries field names, while Avro strips names from the payload and relies on writer and reader schemas, often from a registry, trading self description for smaller messages and strong evolution.