Protocol Buffer Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 8: Line 8:
* It allows defining types, and the data is fully typed when exchanged. We know the type of data in transit.
* It allows defining types, and the data is fully typed when exchanged. We know the type of data in transit.
* Data is compressed automatically.
* Data is compressed automatically.
* Serialization/deserialization is efficient.
* Comes with a schema (the <code>.proto</code>) file, which is used to generate code that writes and reads the data.
* Comes with a schema (the <code>.proto</code>) file, which is used to generate code that writes and reads the data.
* Schema supports embedded documentation.
* Schema supports embedded documentation.

Revision as of 23:20, 6 May 2024

Internal

Overview

The main use case for Protocol Buffers is sharing data across programming languages. Data can be written and serialized in one language, sent over the network and then and deserialized and interpreted in a different programming language, without compatibility problems.

Protocol Buffers comes with the following advantages:

  • It allows defining types, and the data is fully typed when exchanged. We know the type of data in transit.
  • Data is compressed automatically.
  • Serialization/deserialization is efficient.
  • Comes with a schema (the .proto) file, which is used to generate code that writes and reads the data.
  • Schema supports embedded documentation.
  • Schema can evolve over time in a safe manner. The implementation can be maintained to be backward and forward compatible.

One of the disadvantages is that the data is encoded in a binary format, so it can't be visualized with a text editor.

gRPC uses Protocol Buffers as default serialization format and native mechanism to exchange data.

The current version of the protocol is 3, released mid 2016.

Data Evolution with Protocol Buffers

TO MERGE

Overview

Protocol buffers is a format used for data serialization, publicly introduced by Google in 2008. The benefits of using Protocol Buffers include the simplicity of the definition language, a small data output size, high performance of serialization and deserialization and the ability to define derives in addition to data structures and compile client and server code in multiple languages.

Protocol Buffer can be used as serialization format for microservices. Additionally, the Protocol Buffer schema languages allows declaring service APIs. Code for those services can then be generated automatically.

gRPC uses Protocol Buffers as serialization format.

Message

A message is actually a type. "Message" is used probably because the instances of the types defines as such are mainly intended to be sent over the wire.