You Might Be Using The Wrong Compression Algorithm

If you work in data engineering, you’ve probably used gzip, Snappy, LZ4, or Zstandard (zstd). More likely — you inherited them. Either the person who set these defaults is long gone, there’s never enough time to revisit the choice, or things work well enough and you’d rather not go digging.

Most engineers stick with the defaults. Changing them feels risky. And let’s be honest — many don’t really know what these algorithms do or why one was chosen in the first place.

I’ve been that person myself: “Oh, we’re using Snappy? OK.” Never thinking to ask why, or what else we could use.

This post explains the most common compression algorithms, what makes them different, and when you should actually use each.

Reproducible Benchmark

The recommendations below are now backed by an open, reproducible benchmark. View the GitHub repository or open the live July 2026 report. The benchmark downloads public datasets on demand and publishes exact settings, raw samples, summary CSVs, hardware details, and matrix charts.

Why Compression Choices Matter

Compression decisions aren’t just about saving space. They directly impact:

In modern pipelines — Kafka, Parquet, column stores, data lakes — the wrong compression algorithm can degrade all of these.

Two metrics matter most:

Your workload — and whether you prioritize CPU, latency, or bandwidth — determines which trade-offs are acceptable.

Main Culprits

gzip

Snappy

LZ4

zstd (Zstandard)

Brotli

What it is: A modern codec developed by Google and widely used for HTTP content. Measured result: 3.60× ratio, 34 MB/s compression, and 219 MB/s decompression on enwik9 at level 5. When to use: Web assets and static content when better density than gzip is worth additional compression CPU.

XZ/LZMA

What it is: A high-density codec commonly used for archives and software distribution. Measured result: The best enwik9 ratio at 4.34×, but only 1.3 MB/s compression and 61 MB/s decompression at level 6. When to use: One-time archival or static distribution, not latency-sensitive pipelines.

Strengths and Weaknesses (At a Glance)

Algorithm Compression Ratio Compression Speed Decompression Speed Best For
gzip Moderate Slow Moderate Archival, web content
Snappy Low Very Fast Very Fast Real-time, low-CPU systems
LZ4 Moderate Extremely Fast Extremely Fast High-throughput, low-latency systems
zstd High Fast Fast General-purpose, Parquet, Kafka, data transfers
Brotli High Slow Fast HTTP and static web content
XZ/LZMA Very High Extremely Slow Slow One-time archival and distribution

Live Benchmark Results

The July 2026 standard run processed 2.43 GiB of public data with six codecs, five measured repetitions per case, and zero failures. These enwik9 results show the trade-off on a 1 GB Wikipedia text input:

Codec Ratio Compress MB/s Decompress MB/s RSS MiB
gzip 6 3.09× 18 178 30.5
Snappy 1 1.97× 313 358 35.4
LZ4 0 1.96× 344 634 33.0
zstd 3 3.19× 114 142 41.9
Brotli 5 3.60× 34 219 60.8
XZ 6 4.34× 1.3 61 110.9

On 977.8 MiB of GitHub Archive JSON, zstd reached an 11.3× ratio at 389 MB/s, while LZ4 decompressed at 617 MB/s and Snappy compressed at 570 MB/s. The data type changes the result, so use the matrices rather than treating one codec as universally best. Explore the live result matrices.

Real-World Scenarios: When to Use What

High-throughput streaming (Kafka)

Long-term storage (Parquet, S3)

Low-latency querying (DuckDB, Cassandra)

CPU/memory constrained environments

Fast network, low compression benefit (datacenter file transfer)

Slow network or internet transfers

What to Remember

What’s Underneath The Hood

Why it matters: Most compression algorithms combine finding patterns (LZ77) with efficient encoding (Huffman, FSE) to shrink data without losing information.

Closing Thoughts

Compression choices tend to stick around. There’s rarely time to revisit legacy pipelines, and if something works, it’s easy to assume it’s good enough. But if you can make the time, you’re now better equipped to review your defaults — and see if a different choice might better fit your needs.