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.
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.
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.
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.
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
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.
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,.pngand.gif. - Content types
video/*,audio/*,application/zip,application/x-gzip,application/x-zip-compressed,application/x-compressandapplication/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:
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.




