2019-04-09 14:39:42 -04:00
|
|
|
# Compression Guide [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io)
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
MinIO server allows streaming compression to ensure efficient disk space usage.
|
|
|
|
Compression happens inflight, i.e objects are compressed before being written to disk(s).
|
|
|
|
MinIO uses [`klauspost/compress/s2`](https://github.com/klauspost/compress/tree/master/s2)
|
2021-01-05 23:08:35 -05:00
|
|
|
streaming compression due to its stability and performance.
|
2019-09-26 02:08:24 -04:00
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
This algorithm is specifically optimized for machine generated content.
|
2021-01-05 23:08:35 -05:00
|
|
|
Write throughput is typically at least 500MB/s per CPU core,
|
2022-02-11 19:51:25 -05:00
|
|
|
and scales with the number of available CPU cores.
|
2021-01-05 23:08:35 -05:00
|
|
|
Decompression speed is typically at least 1GB/s.
|
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
This means that in cases where raw IO is below these numbers
|
2021-01-05 23:08:35 -05:00
|
|
|
compression will not only reduce disk usage but also help increase system throughput.
|
2022-02-11 19:51:25 -05:00
|
|
|
Typically, enabling compression on spinning disk systems
|
2021-01-05 23:08:35 -05:00
|
|
|
will increase speed when the content can be compressed.
|
2018-09-27 23:36:17 -04:00
|
|
|
|
|
|
|
## Get Started
|
|
|
|
|
|
|
|
### 1. Prerequisites
|
|
|
|
|
2019-04-09 14:39:42 -04:00
|
|
|
Install MinIO - [MinIO Quickstart Guide](https://docs.min.io/docs/minio-quickstart-guide).
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2019-04-09 14:39:42 -04:00
|
|
|
### 2. Run MinIO with compression
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
Compression can be enabled by updating the `compress` config settings for MinIO server config.
|
2021-01-05 23:08:35 -05:00
|
|
|
Config `compress` settings take extensions and mime-types to be compressed.
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2021-01-05 23:08:35 -05:00
|
|
|
```bash
|
|
|
|
~ mc admin config get myminio compression
|
2020-05-24 21:34:47 -04:00
|
|
|
compression extensions=".txt,.log,.csv,.json,.tar,.xml,.bin" mime_types="text/*,application/json,application/xml"
|
2020-01-21 05:20:54 -05:00
|
|
|
```
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
Default config includes most common highly compressible content extensions and mime-types.
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2021-01-05 23:08:35 -05:00
|
|
|
```bash
|
|
|
|
~ mc admin config set myminio compression extensions=".pdf" mime_types="application/pdf"
|
2018-09-27 23:36:17 -04:00
|
|
|
```
|
|
|
|
|
2020-06-11 21:14:13 -04:00
|
|
|
To show help on setting compression config values.
|
2022-02-11 19:51:25 -05:00
|
|
|
|
2021-01-05 23:08:35 -05:00
|
|
|
```bash
|
2019-11-30 00:37:42 -05:00
|
|
|
~ mc admin config set myminio compression
|
2018-09-27 23:36:17 -04:00
|
|
|
```
|
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
To enable compression for all content, no matter the extension and content type
|
2021-01-05 23:08:35 -05:00
|
|
|
(except for the default excluded types) set BOTH extensions and mime types to empty.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
~ mc admin config set myminio compression enable="on" extensions="" mime_types=""
|
2020-06-11 21:14:13 -04:00
|
|
|
```
|
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
The compression settings may also be set through environment variables.
|
2021-01-05 23:08:35 -05:00
|
|
|
When set, environment variables override the defined `compress` config settings in the server config.
|
2018-09-27 23:36:17 -04:00
|
|
|
|
|
|
|
```bash
|
2022-07-17 11:43:14 -04:00
|
|
|
export MINIO_COMPRESSION_ENABLE="on"
|
|
|
|
export MINIO_COMPRESSION_EXTENSIONS=".txt,.log,.csv,.json,.tar,.xml,.bin"
|
|
|
|
export MINIO_COMPRESSION_MIME_TYPES="text/*,application/json,application/xml"
|
2018-09-27 23:36:17 -04:00
|
|
|
```
|
|
|
|
|
2021-01-05 23:08:35 -05:00
|
|
|
### 3. Compression + Encryption
|
|
|
|
|
|
|
|
Combining encryption and compression is not safe in all setups.
|
|
|
|
This is particularly so if the compression ratio of your content reveals information about it.
|
|
|
|
See [CRIME TLS](https://en.wikipedia.org/wiki/CRIME) as an example of this.
|
|
|
|
|
|
|
|
Therefore, compression is disabled when encrypting by default, and must be enabled separately.
|
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
Consult our security experts on [SUBNET](https://min.io/pricing) to help you evaluate if
|
2021-01-05 23:08:35 -05:00
|
|
|
your setup can use this feature combination safely.
|
|
|
|
|
|
|
|
To enable compression+encryption use:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
~ mc admin config set myminio compression allow_encryption=on
|
|
|
|
```
|
|
|
|
|
2022-07-17 11:43:14 -04:00
|
|
|
Or alternatively through the environment variable `MINIO_COMPRESSION_ALLOW_ENCRYPTION=on`.
|
2021-01-05 23:08:35 -05:00
|
|
|
|
|
|
|
### 4. Excluded Types
|
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
- Already compressed objects are not fit for compression since they do not have compressible patterns.
|
2021-01-05 23:08:35 -05:00
|
|
|
Such objects do not produce efficient [`LZ compression`](https://en.wikipedia.org/wiki/LZ77_and_LZ78)
|
|
|
|
which is a fitness factor for a lossless data compression.
|
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
Pre-compressed input typically compresses in excess of 2GiB/s per core,
|
2021-01-05 23:08:35 -05:00
|
|
|
so performance impact should be minimal even if precompressed data is re-compressed.
|
|
|
|
Decompressing incompressible data has no significant performance impact.
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2021-01-05 23:08:35 -05:00
|
|
|
Below is a list of common files and content-types which are typically not suitable for compression.
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
- Extensions
|
|
|
|
|
|
|
|
| `gz` | (GZIP) |
|
|
|
|
| `bz2` | (BZIP2) |
|
|
|
|
| `rar` | (WinRAR) |
|
|
|
|
| `zip` | (ZIP) |
|
|
|
|
| `7z` | (7-Zip) |
|
|
|
|
| `xz` | (LZMA) |
|
|
|
|
| `mp4` | (MP4) |
|
|
|
|
| `mkv` | (MKV media) |
|
|
|
|
| `mov` | (MOV) |
|
|
|
|
|
|
|
|
- Content-Types
|
|
|
|
|
|
|
|
| `video/*` |
|
|
|
|
| `audio/*` |
|
|
|
|
| `application/zip` |
|
|
|
|
| `application/x-gzip` |
|
|
|
|
| `application/zip` |
|
|
|
|
| `application/x-bz2` |
|
|
|
|
| `application/x-compress` |
|
|
|
|
| `application/x-xz` |
|
|
|
|
|
|
|
|
All files with these extensions and mime types are excluded from compression,
|
2021-01-05 23:08:35 -05:00
|
|
|
even if compression is enabled for all types.
|
2019-09-26 02:08:24 -04:00
|
|
|
|
2021-01-05 23:08:35 -05:00
|
|
|
### 5. Notes
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2022-02-27 17:54:37 -05:00
|
|
|
- MinIO does not support compression for Gateway implementations.
|
2018-09-27 23:36:17 -04:00
|
|
|
|
|
|
|
## To test the setup
|
|
|
|
|
2022-02-11 19:51:25 -05:00
|
|
|
To test this setup, practice put calls to the server using `mc` and use `mc ls` on
|
2021-01-05 23:08:35 -05:00
|
|
|
the data directory to view the size of the object.
|
2018-09-27 23:36:17 -04:00
|
|
|
|
|
|
|
## Explore Further
|
|
|
|
|
2019-04-09 14:39:42 -04:00
|
|
|
- [Use `mc` with MinIO Server](https://docs.min.io/docs/minio-client-quickstart-guide)
|
|
|
|
- [Use `aws-cli` with MinIO Server](https://docs.min.io/docs/aws-cli-with-minio)
|
|
|
|
- [Use `s3cmd` with MinIO Server](https://docs.min.io/docs/s3cmd-with-minio)
|
|
|
|
- [Use `minio-go` SDK with MinIO Server](https://docs.min.io/docs/golang-client-quickstart-guide)
|
|
|
|
- [The MinIO documentation website](https://docs.min.io)
|