Skip to content
About
Main content
Bytes at Rest

Encoding, Serialization & Compression

What do we turn our values into when we turn them into bytes, and what does that choice cost?

Who this mechanism is for: a developer who writes code, sends JSON over HTTP, maybe uses or files, but has never studied how values become bytes, why one file format is ten times smaller than another, or what "" really does. You do not need any database or systems knowledge. Every technical term is explained the first time it appears, and again in the glossary at the end.

The story we will follow

Nikhil is a backend engineer at Tradewind, a small logistics start-up that tracks parcels. Warehouse scanners create a scan event each time a parcel is scanned: which parcel, which scanner, the time (in microseconds), a status such as LOADED or DELIVERED, the weight in grams, a latitude and longitude, the depot name, and an optional list of handling notes. Tradewind receives about 400 million of these events per month. Each event carries only about 40 bytes of real information. The events travel through a message queue (a Kafka topic called scans), are written in batches as Parquet files into cloud , and are then queried by dashboards and analysts. The data is kept for three years.

Nikhil owns this pipeline. Sofia is the data platform lead. She reviews formats, owns the storage bill and asks the questions that Nikhil would prefer to have asked himself. During one busy quarter Nikhil will meet five problems, one at the start of each article below. Each problem looks like a bug. Each one is actually a consequence of how values are mapped to bytes. At the end of each article we go back and solve it.

The main idea of this whole mechanism:

How this mechanism is organized

After that: a summary, hands-on labs, interview questions and a glossary.

One request: do not skip the numbers. This mechanism gives many sizes and speeds ("22 bytes", "0.3–4 GB/s"). The ratios between them are the real content.

What do I do, and what does each option cost?

Can I see it myself?

Can I reason about it under questioning?

Trade-offs

The tensions this mechanism takes a position on. Each recurs across mechanisms.

Show all 12 trade-offs
Recurring principles

Ideas this mechanism meets that keep coming back, mechanism after mechanism.