Protocol Buffers
Protocol Buffers is Google's language-neutral binary serialization format; it requires a .proto schema definition and is more compact and type-safe than JSON/XML.
Purpose
To provide strongly typed, compact, and efficient cross-language data exchange, with schemas guaranteeing compatibility.
Mechanism
A .proto IDL defines message types with field numbers. When encoding, each field starts with a (field_number<<3 | wire_type) tag; integers use varint, and strings and nested messages use length prefixes. Unknown fields stay forward-compatible. proto3 simplifies the syntax.
Use cases
- gRPC transport protocol
- Google internal data storage
- Mobile APIs (saving bandwidth)
- Configuration and persistence
Examples
- Input
message User { string name = 1; }OutputBinary encodingRequires protoc compilation
Common errors
- Changing field numbers breaks compatibility
- Once assigned, numbers must not be reused or changed
Related terms
Avro
Avro is a row-oriented binary serialization format from the Hadoop ecosystem; its schema is embedded or external, and it is used for big data storage and Kafka. GLOSSARY
JSON
JSON (JavaScript Object Notation) is a lightweight data interchange format based on JavaScript object literals, using key-value pairs and arrays. GLOSSARY
CBOR
CBOR (Concise Binary Object Representation) is a binary form of JSON, standardized in RFC 8949, more compact and supporting more data types. GLOSSARY