Protocol Buffers Overview

Protocol Buffers (Protobuf) is a free and open-source cross-platform library created by Google and used to serialize structured data. According to the official website, “Protocol Buffers are a language-neutral, platform-neutral extensible mechanism for serializing structured data in a forward-compatible and backward-compatible way”.

Usage

Protobuf has three main components that we have to deal with:

  1. Message descriptors: when using Protobuf we have to define our messages structures in .proto files following a specific syntax.

  2. Message implementations: messages definitions are not enough to represent and exchange data. We have to generate classes/objects to deal with data in the chosen programming language using the corresponding Protocol Compiler provided by Google.

  3. Parsing and Serialization. After defining and creating Protobuf messages, we need to be able to exchange these messages. Luckily, Google provides us useful libraries to achieve this, as long as we use one of the supported programming language.

Advantages and disadvantages

Pros:

●       More efficient parsing - Parsing with Protocol Buffers is less CPU-intensive because data is represented in a binary format which minimizes the size of encoded messages (it’s way faster than JSON as showed in the following picture).

●       Predefined Schema - messages structure it’s known by all the services.

Cons:

●       Lack of resources - it’s difficult to find lots of resources about using and developing with Protobuf.

●       Lack of support - Google does not provide support for other programming languages like Swift, R, Scala and etc.

●       Non-human readability - ProtoBuf is exchanged using a binary format, that’s why it’s so performant. However, compared to JSON, it’s more difficult to be read and analyzed by humans.

Previous
Previous

TEAMING. AI met in Spain

Next
Next

The use of Docker in modern software development