liveBook · Manning

Protocol buffer

As explained in Latency

Protocol Buffers is a cross-platform binary serialization format commonly used for encoding messages in remote procedure calls.

A protocol buffer is a binary serialization format used to encode messages, including data exchanged through remote procedure calls. Serialization converts in-memory values into a transport or storage representation; deserialization reverses that transformation. section 7.3

Protocol buffers matter when latency is important because serialization consumes CPU cycles and can require costly memory copies. The surrounding workflow includes in-memory structures, network APIs, RPC boundaries, and data-store formats. section 7.3

Order message across an API

An online-store client can serialize an order containing an order ID and quantity, send it to an API or RPC service, and have the receiver deserialize it for processing. The same order may be serialized again for storage. section 7.3

Figure 7.2 Serialization transforms the in-memory representation of data (shown on the left as a Rust struct) to a serialized format such as JSON (shown on the right). Deserialization performs the opposite transformation from a serialized format to an in-memory representation.
Figure 7.4: Serialization transforms in-memory representation to a serialized format such as JSON. Deserialization performs the opposite transformation from serialized format to in-memory representation.

Trace the transformation between a Rust in-memory order structure and its serialized representation, then reverse it through deserialization. section 7.3

How Latency covers it

How deep it goes
Explains serialization costs, memory representation, fields, precision, and byte order, but stops short of protocol-buffer encoding internals.
Examples
Uses an online-store order with order ID and quantity, represented as a Rust struct and serialized for JSON, RPC, or storage.
What it assumes
Assumes familiarity with in-memory data, network APIs, and RPC while explaining serialization and deserialization from their operational effects.
What you can do after
Evaluate serialization work as a source of latency, CPU consumption, and memory-copy overhead across application boundaries.
How it connects
Connects protocol buffers with serialization, deserialization, remote procedure calls, REST APIs, JSON, and in-memory data structures.

Also explained in

Compare how 10 books explain protocol buffer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Latency. The section links point to the parts of the book it draws on.