Transparent Data Compression on MinIO

Looking upward inside a tall metal tower with intersecting beams and tension cables in black and white.

AIStor compresses objects as they are written and decompresses them as they are read. Applications see the same bytes, sizes and ETags, and the drives hold less. A lot has changed since our first post on the subject: a new codec, a new block format that decodes with SIMD, per-bucket rules, and a way to compress the data you already stored.

1.95×

faster decompression per core than the previous default

6.2 GB/s

of data decompressed per core, up from 3.2 GB/s

17%

less disk, at the same compression speed

‍

MinLZ SIMD Balanced, AIStor's new default on amd64, compared with MinLZ Balanced, the previous default. Geometric mean over 13 data sets on an AMD Ryzen 9 9950X. Details below in the The Numbers section.

What Changed

  • SIMD blocks. MinLZ's new block type decompresses about twice as fast per core and stores 17% less. AIStor switches to it automatically once every node in the cluster can read it.
  • MinLZ replaced S2. Since our first post, uploads are compressed with MinLZ, the successor to S2. At the same speed it stores about 11% less.
  • Per-bucket policies. Each bucket can have its own ordered list of include and exclude rules, by prefix, extension, content type, size, tags or metadata.
  • Compression for data at rest. A lifecycle action and a batch job compress, or recompress harder, objects that are already stored.
  • Encryption needs no opt-in. Encrypted objects compress like any other object.
  • Visibility. Compression ratio and bytes saved show up in mc stat, the console and Prometheus.

Everything written by earlier releases, with S2 or Snappy, reads exactly as before. There is nothing to migrate.

How It Works

When an upload matches the compression rules, AIStor compresses it inline, on the way to the drives. There is no background job and no second copy. The compressed stream is then encrypted if the object is encrypted, and erasure coded like any other object. A read reverses the steps on the fly.

  1. Split

    The object is cut into 2 MiB blocks.

  2. Compress

    Up to 8 blocks of one object compress in parallel. A block that does not shrink is stored as is.

  3. Index

    Parts over 8 MiB get an index of block offsets, so a ranged read can start at any block.

  4. Encrypt

    For SSE objects the compressed stream is encrypted, padded to a multiple of 256 bytes.

  5. Erasure code

    Data and parity shards are written across the erasure set as usual.

‍

Clients only ever see the original data. Size, ETag and checksums describe the uncompressed object, and a compressed object answers GET and HEAD with X-Minio-Compressed: minlz.

Compression is a local storage property of each site. Replication sends the decoded object and the target compresses it according to its own settings, so sites can run different compression configurations. The exception is SSE-C, where the server cannot decrypt the data: those objects replicate as stored, together with their compression state.

MinLZ

MinLZ is the successor to S2, from the same author. The goals have not changed: LZ77 compression at IO speed, independent blocks that compress and decompress in parallel, and streams you can seek in. Better match finding and a tighter encoding store about 11% less than S2 at about the same speed, and decompression is 13% faster even with classic blocks.

AIStor uses three levels:

  • Balanced for uploads on amd64.
  • Fastest for uploads on other platforms.
  • Smallest for the opt-in high compression passes over stored data. It is much slower, which is why it runs in the background and never on the upload path.

SIMD Blocks

MinLZ 1.3 adds a second block type. A SIMD block keeps the literals and the match operations in separate Huffman-coded streams, laid out so they decode with AVX2, AVX-512 or NEON instructions. At AIStor's 2 MiB block size it compresses about as fast as a classic block, stores about 17% less, and decompresses about twice as fast.

AIStor writes SIMD blocks when all of these hold:

  • The node's CPU has the SIMD instructions: AVX2 on amd64, or any arm64 CPU.
  • Every node can read them. Older releases cannot decode SIMD blocks, so AIStor waits until the cluster API version shows that every node runs a release that can. After an upgrade, writes switch over by themselves once the API version moves forward.
  • The object is at least 32 KiB. Each SIMD block carries its own Huffman tables, so smaller objects keep classic blocks.
  • The object is not SSE-C. SSE-C objects replicate as stored, and the target site may run an older release.

Every node reads both block types, whatever its CPU. Objects compressed before the upgrade keep their classic blocks until something rewrites them.

The Numbers

We measured each codec in memory with gocomp on an AMD Ryzen 9 9950X, at the block size AIStor uses: 2 MiB for MinLZ and 1 MiB for S2. Single-core figures show the cost per core; 16-thread figures show what one object can reach, since AIStor compresses its blocks in parallel. Results are geometric means over 13 data sets, from logs and JSON to database files, disk images and backups.

Decompression speed per core

GB/s of original data produced by one core. This is what every read of a compressed object costs.

Decompression speed per core, GB/s
CodecGB/s per core
MinLZ SIMD Balanced6.23 (1.95× faster than the previous default)
LZ44.36
MinLZ Balanced3.19
S2 Better2.84
Zstandard default2.73
gzip level 60.62

The new default decompresses 1.95 times as fast per core as the previous one, and more than twice as fast as S2. Faster decompression means faster reads, and more CPU left for everything else on a busy node.

Compression speed against compression ratio

Higher is faster, further right is smaller output. Each line connects the levels of one codec, and the large dots mark the default for uploads on amd64: MinLZ Balanced before, MinLZ SIMD Balanced now.

Compression speed per core, MB/s
1,8001,5001,200 900600300 0
3.54.04.5 5.05.56.0 6.5
Compression ratio
Compression speed per core (MB/s) against compression ratio
Codec and levelCompression ratioMB/s per core
MinLZ SIMD Fastest5.141,570
MinLZ SIMD Balanced (default now)5.46875
MinLZ SIMD Smallest6.28133
MinLZ Fastest4.151,551
MinLZ Balanced (default before)4.55885
MinLZ Smallest5.16122
S2 Default3.711,570
S2 Better4.03926
S2 Best4.4062
LZ43.68785
Zstandard fastest5.35715
Zstandard default5.74588
gzip level 65.08287

At every speed, MinLZ SIMD stores less than classic MinLZ and S2. Zstandard's default level stores about 5% less than SIMD Balanced, at two thirds of its compression speed and less than half of its decompression speed.

All Codecs and Levels

Codec and level Decompress, 1 core vs previous default Ratio Disk vs previous default Compress, 1 core Compress, 16 threads
MinLZ SIMD FastestDefault for uploads on arm64 6,456 MB/s2.02×5.14−11.6%1,570 MB/s17,376 MB/s
MinLZ SIMD BalancedDefault for uploads on amd64 6,230 MB/s1.95×5.46−16.6%875 MB/s10,403 MB/s
MinLZ SIMD SmallestHigh compression passes 6,382 MB/s2.00×6.28−27.6%133 MB/s926 MB/s
MinLZ Fastest 3,364 MB/s1.05×4.15+9.6%1,551 MB/s18,192 MB/s
MinLZ BalancedPrevious default for uploads on amd64 3,193 MB/s—4.55—885 MB/s10,742 MB/s
MinLZ Smallest 3,598 MB/s1.13×5.16−11.9%122 MB/s925 MB/s
S2 Default 3,078 MB/s0.96×3.71+22.6%1,570 MB/s18,315 MB/s
S2 Betteramd64 default before MinLZ 2,835 MB/s0.89×4.03+13.0%926 MB/s11,430 MB/s
S2 Best 2,959 MB/s0.93×4.40+3.3%62 MB/s741 MB/s
Zstandard fastest 2,570 MB/s0.80×5.35−15.0%715 MB/s6,033 MB/s
Zstandard default 2,731 MB/s0.86×5.74−20.7%588 MB/s4,564 MB/s
LZ4 4,359 MB/s1.37×3.68+23.5%785 MB/s8,261 MB/s
gzip level 6 616 MB/s0.19×5.08−10.5%287 MB/s—

Geometric means over the 13 data sets below. The previous default is MinLZ Balanced. Ratio is original size divided by compressed size, and speeds are megabytes of original data per second. gzip has no multi-threaded mode.

By Data Set

The gain depends on the data. Decompression speeds up most on data with many literals, such as prose, comments and mixed files, because SIMD blocks decode their Huffman-coded literals many at a time. Highly repetitive logs were already fast to decompress, so they gain less speed but the most space.

Data set Size Decompress, 1 core Faster Ratio Less disk
English Wikipedia XML (enwik9) 1.0 GB1.6 → 4.9 GB/s3.12×2.6 → 3.116%
Reddit comments, January 2009 609 MB2.0 → 5.1 GB/s2.64×3.6 → 4.315%
Silesia compression corpus 212 MB2.0 → 5.2 GB/s2.54×2.6 → 3.115%
10M New York taxi trips 3.3 GB2.5 → 5.6 GB/s2.27×4.2 → 5.421%
Mixed 10 GB file archive 10.1 GB2.5 → 5.6 GB/s2.22×1.9 → 2.110%
Rawstudio Mint 14 image set 8.6 GB2.7 → 5.6 GB/s2.03×2.2 → 2.513%
GitHub ranking database dump 1.9 GB2.9 → 5.3 GB/s1.84×3.6 → 4.520%
Two days of GitHub events 6.3 GB4.0 → 7.3 GB/s1.82×6.8 → 8.318%
Go gob-encoded object stream 1.9 GB3.8 → 6.8 GB/s1.78×6.9 → 8.014%
Consensus database snapshot 10.7 GB4.7 → 7.7 GB/s1.65×2.5 → 2.66%
1M LA parking citations 365 MB4.3 → 6.7 GB/s1.55×9.1 → 11.621%
Apache access log 2.6 GB6.0 → 9.2 GB/s1.53×14.9 → 19.222%
CockroachDB node log 10.5 GB6.3 → 7.5 GB/s1.19×14.6 → 19.124%

Each pair is MinLZ Balanced, the previous default, followed by MinLZ SIMD Balanced, the new one. "Less disk" is how much smaller the new output is for the same data.

Incompressible Data

Compression has no guaranteed ratio. Data that is already compressed or encrypted will not shrink, and the question is what trying costs. On 2 GB of random data, MinLZ SIMD Balanced works through 9.7 GB/s per core and stores each block as is, with a few bytes of framing. Reading it back runs at 12.5 GB/s per core, essentially a memory copy.

AIStor also skips formats that are known to be compressed, even when compression is enabled for everything:

  • Extensions .gz, .bz2, .rar, .zip, .7z, .xz, .mp4, .mkv, .mov, .jpg, .png and .gif.
  • Content types video/*, audio/*, application/zip, application/x-gzip, application/x-zip-compressed, application/x-compress and application/x-spoon.
  • Objects of 4 KiB or less.

A client that knows better can send x-minio-compress: true on PutObject or CreateMultipartUpload to compress that upload regardless of the rules.

Choosing What to Compress

Compression is off until you enable it. The global settings apply to every bucket that has no policy of its own:

mc admin config set myminio compression enable=on \
  extensions=".txt,.log,.csv,.json,.tar,.xml,.bin" \
  mime_types="text/*,application/json,application/xml,binary/octet-stream"

‍

Those extensions and content types are the defaults. Set both to an empty string to compress everything except the excluded formats. You can also narrow the rules:

Key Effect
extensions Compress object names ending in these suffixes, case-insensitive
mime_types Compress objects with a matching Content-Type, wildcards allowed
min_size, max_size Only compress objects within this size window, for example 8KiB to 1GiB
tags Only compress objects that carry these object tags
metadata Only compress objects that carry these x-amz-meta-* headers
match Compare tag and metadata values as exact matches or as contains substrings

‍

An object is compressed when it passes every group that is set: the size window, the extensions or content types, every tag and every metadata entry. Every key also has a MINIO_COMPRESSION_<KEY> environment variable.

Per-bucket Policies

A bucket can have its own policy, which replaces the global settings for that bucket. A policy is an ordered list of rules, and the first rule that matches decides. Rules take the same filters as the global settings plus prefixes, and a rule can exclude what it matches. Put an exclusion before the broader rule it carves out of:

{
  "enabled": true,
  "rules": [
    { "prefixes": ["logs/archive/"], "exclude": true },
    { "prefixes": ["logs/"], "minSize": 8192 }
  ]
}

‍

This compresses everything under logs/ above 8 KiB, except logs/archive/. Set policies in the console under Buckets → Compression, with the madmin SDK, or through the admin API (set-bucket-compression, get-bucket-compression and delete-bucket-compression). A policy with "enabled": false turns compression off for the bucket; deleting the policy returns the bucket to the global settings.

Compressing Data You Already Stored

Upload rules only affect new writes. Two features compress what is already on disk, by re-encoding each version in place:

  • A lifecycle action for ongoing policies, such as compressing logs 30 days after they are written.
  • A batch job for a one-off pass over a bucket or prefix.

Both are invisible to clients. A re-encoded version keeps its version ID, ETag, modification time, metadata, tags and part layout. The work runs on every node at once, each node handling the objects of its own erasure sets. Nothing leaves the cluster, and nothing triggers replication.

# compress objects under logs/ 30 days after they are written,
# and noncurrent versions 7 days after they are replaced
mc ilm rule add --prefix "logs/" --compress-days 30 \
  --noncurrent-compress-days 7 myminio/mybucket

# the same, but recompress at the strongest level
mc ilm rule add --prefix "logs/" --compress-days 30 \
  --noncurrent-compress-days 7 --compress-high myminio/mybucket

‍

# a one-off pass with a batch job
mc batch generate myminio compress > compress.yaml
mc batch start myminio ./compress.yaml
mc batch status myminio <job-id>

‍

compress:
  apiVersion: v1
  bucket: mybucket
  prefix: myprefix
  highCompression: false   # true recompresses at the strongest level
  skipCompressed: false    # true leaves already-compressed objects alone
  includeEncrypted: false  # true also covers SSE-S3 and SSE-KMS objects
  filter:
    olderThan: "7d"

‍

By default both only compress objects stored uncompressed, at the level an upload would use, so the cost is predictable. With high compression they also recompress compressed objects at MinLZ's strongest level. With SIMD blocks that stores 28% less than the previous upload default, and still decompresses twice as fast. That includes objects written with S2 by older releases. Objects already at the strongest level are left alone, so running a rule or a job again costs nothing.

SSE-S3 and SSE-KMS objects are included when you ask for them, and keep their existing object key. SSE-C objects are never touched, because the server does not keep the customer's key. mc batch status reports objects compressed and skipped, and the bytes reclaimed.

Reading Part of an Object

Ranged reads stay fast. Every part larger than 8 MiB stores an index of its block offsets, so a GET with a range starts decompressing at the 2 MiB block that holds the first requested byte, rather than at the start of the part.

Compression and Encryption

AIStor always compresses first and encrypts the result, so encrypted objects compress as well as any other object. This used to need allow_encryption=on; that setting is no longer needed and is ignored.

SIZE AND CONFIDENTIALITY
‍
The size of compressed data says something about its content. AIStor pads encrypted compressed objects to a multiple of 256 bytes, and the S3 API only reports the original size of an object. Each object, version and append is compressed on its own, so data from different writes never shares a compression context.

Seeing What You Saved

The scanner measures the logical and on-disk size of every compressed version, so the figures stay correct as objects are overwritten and recompressed. They cover compressed objects only, so uncompressed data does not dilute the ratio.

$ mc stat myminio/mybucket
...
Compressed: 1,234 versions, 3.10x ratio, saved 4.2 GiB

‍

The console has a Compression page per bucket, and Prometheus has cluster and bucket metrics, including minio_cluster_usage_buckets_compressed_logical_bytes and minio_cluster_usage_buckets_compressed_physical_bytes. The ratio is logical divided by physical.

Fully Backwards Compatible

  • Objects written with Snappy or S2 by earlier releases read exactly as before, next to MinLZ objects in the same bucket.
  • Nothing has to be migrated. A high compression pass moves old objects to MinLZ when you want the space back.
  • Rolling upgrades are safe. New nodes write classic MinLZ blocks until every node can read SIMD blocks, then switch.
  • Replication sends objects decoded, so sites can use different compression settings.

As with every feature that changes the cluster API version, a cluster cannot go back to a release from before that version once it has moved forward.

Getting Started

Compression costs little CPU and needs no changes to applications. On logs, CSV and JSON it typically cuts storage by 75% or more, and with MinLZ SIMD blocks reading that data back is faster than it has ever been.

# compress the default text-like types on every bucket
mc admin config set myminio compression enable=on

# compress existing logs in one bucket
mc ilm rule add --prefix "logs/" --compress-days 0 myminio/mybucket

# see what it saved
mc stat myminio/mybucket

‍

How We Measured

All numbers come from gocomp, run in memory on an AMD Ryzen 9 9950X (16 cores) with Go. MinLZ is a development build of the 1.3 release line, S2, Zstandard and gzip come from klauspost/compress v1.20.3, and LZ4 from pierrec/lz4 v4.1.30. Each codec ran at its default block size, which is the size AIStor uses for MinLZ (2 MiB) and used for S2 (1 MiB). "1 core" is a single thread; "16 threads" runs the block-parallel encoder on 16 threads. Each data set was compressed whole, and the figures above are geometric means over these 13 data sets: Apache access log, CockroachDB node log, consensus database snapshot, enwik9, two days of GitHub events, GitHub ranking database dump, Go gob-encoded object stream, New York taxi trips, LA parking citations, Rawstudio Mint 14 image set, Reddit comments, Silesia corpus and a mixed 10 GB file archive. The random data is 2 GB of PCG output.

Conclusion

MinIO AIStor offers the best-in-class compression scheme that allows for fully transparent compression of data on disk. This can in many scenarios lead to a reduction in storage costs, simply by enabling compression.

GET and PUT performance should in all cases remain close to the same when compression is enabled. In fact, in situations where performance is limited by disk read speed, compression may offer additional performance since less data has to be read.

If you are interested in these features, download MinIO AIStor and try it out for yourself. If you have any questions or want to tell us about the great apps you’re building using MinIO AIStor, ping us on hello@min.io, join the Slack community, or subscribe to our newsletter.

Whether you're exploring AI-native object storage or planning your next deployment, we'd love to help.
Let's start a conversation — or jump right in and try AIStor yourself.
Contact Us
Download AIStor