🗓️ 06042024 1650
TLDR
Protocol Buffers (often abbreviated as protobuf) are a language-neutral, platform-neutral, extensible mechanism for serializing structured data similar to XML, but smaller, faster, and simpler.
Efficiency
- More efficient in terms of serialisation and deserialisation speed compared to other formats like JSONorXML
- The serialised data is much smaller, which makes it ideal for communication between services or storing data.
Features
Language and Platform Neutral
- Protobuf definitionsare written in a simple configuration file- Can be used to generate code for various programming languages
 
- Easy to share data across different systems or services, regardless of the languages or platforms they use.
Strongly Typed
- Strongly typed data structures
Backward Compatibility
- Can add new fields to your data structures without breaking deployed programs that do not know about them
- Fields can be
- Marked as optional or required
- Deprecated
 
Use Cases
- RPCwhen services need to communicate with each other especially in microservices architectures.
- Storing data in a compact format
- Databases or file systems
 
- High-performance computing and network communication
How It Works
- Define data structure in a .proto file
- Compile: You use the protobuf compiler protoc to generate code from your .proto file for the programming language you're using
- Use the generated code to write and read your structured data to and from various data streams
- files
- pipes
- network connections.
 
References
- ChatGPT