storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/docs/compression/README.md (about)

     1  # Compression Guide [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io)
     2  
     3  MinIO server allows streaming compression to ensure efficient disk space usage. 
     4  Compression happens inflight, i.e objects are compressed before being written to disk(s). 
     5  MinIO uses [`klauspost/compress/s2`](https://github.com/klauspost/compress/tree/master/s2) 
     6  streaming compression due to its stability and performance.
     7  
     8  This algorithm is specifically optimized for machine generated content. 
     9  Write throughput is typically at least 500MB/s per CPU core,
    10  and scales with the number of available CPU cores. 
    11  Decompression speed is typically at least 1GB/s.
    12  
    13  This means that in cases where raw IO is below these numbers 
    14  compression will not only reduce disk usage but also help increase system throughput.
    15  Typically, enabling compression on spinning disk systems 
    16  will increase speed when the content can be compressed.
    17  
    18  ## Get Started
    19  
    20  ### 1. Prerequisites
    21  
    22  Install MinIO - [MinIO Quickstart Guide](https://docs.min.io/docs/minio-quickstart-guide).
    23  
    24  ### 2. Run MinIO with compression
    25  
    26  Compression can be enabled by updating the `compress` config settings for MinIO server config. 
    27  Config `compress` settings take extensions and mime-types to be compressed.
    28  
    29  ```bash
    30  ~ mc admin config get myminio compression
    31  compression extensions=".txt,.log,.csv,.json,.tar,.xml,.bin" mime_types="text/*,application/json,application/xml"
    32  ```
    33  
    34  Default config includes most common highly compressible content extensions and mime-types.
    35  
    36  ```bash
    37  ~ mc admin config set myminio compression extensions=".pdf" mime_types="application/pdf"
    38  ```
    39  
    40  To show help on setting compression config values.
    41  ```bash
    42  ~ mc admin config set myminio compression
    43  ```
    44  
    45  To enable compression for all content, no matter the extension and content type 
    46  (except for the default excluded types) set BOTH extensions and mime types to empty.
    47  
    48  ```bash
    49  ~ mc admin config set myminio compression enable="on" extensions="" mime_types=""
    50  ```
    51  
    52  The compression settings may also be set through environment variables. 
    53  When set, environment variables override the defined `compress` config settings in the server config.
    54  
    55  ```bash
    56  export MINIO_COMPRESS="on"
    57  export MINIO_COMPRESS_EXTENSIONS=".txt,.log,.csv,.json,.tar,.xml,.bin"
    58  export MINIO_COMPRESS_MIME_TYPES="text/*,application/json,application/xml"
    59  ```
    60  
    61  ### 3. Compression + Encryption
    62  
    63  Combining encryption and compression is not safe in all setups.
    64  This is particularly so if the compression ratio of your content reveals information about it.
    65  See [CRIME TLS](https://en.wikipedia.org/wiki/CRIME) as an example of this.
    66  
    67  Therefore, compression is disabled when encrypting by default, and must be enabled separately.
    68  
    69  Consult our security experts on [SUBNET](https://min.io/pricing) to help you evaluate if 
    70  your setup can use this feature combination safely.
    71  
    72  To enable compression+encryption use:
    73  
    74  ```bash
    75  ~ mc admin config set myminio compression allow_encryption=on
    76  ```
    77  
    78  Or alternatively through the environment variable `MINIO_COMPRESS_ALLOW_ENCRYPTION=on`.
    79  
    80  ### 4. Excluded Types
    81  
    82  - Already compressed objects are not fit for compression since they do not have compressible patterns. 
    83  Such objects do not produce efficient [`LZ compression`](https://en.wikipedia.org/wiki/LZ77_and_LZ78)
    84  which is a fitness factor for a lossless data compression.
    85  
    86  Pre-compressed input typically compresses in excess of 2GiB/s per core, 
    87  so performance impact should be minimal even if precompressed data is re-compressed.
    88  Decompressing incompressible data has no significant performance impact.
    89  
    90  Below is a list of common files and content-types which are typically not suitable for compression.
    91  
    92      - Extensions
    93  
    94        | `gz` | (GZIP)
    95        | `bz2` | (BZIP2)
    96        | `rar` | (WinRAR)
    97        | `zip` | (ZIP)
    98        | `7z` | (7-Zip)
    99        | `xz` | (LZMA)
   100        | `mp4` | (MP4)
   101        | `mkv` | (MKV media)
   102        | `mov` | (MOV)
   103  
   104      - Content-Types
   105  
   106        | `video/*` |
   107        | `audio/*` |
   108        | `application/zip` |
   109        | `application/x-gzip` |
   110        | `application/zip` |
   111        | `application/x-bz2` |
   112        | `application/x-compress` |
   113        | `application/x-xz` |
   114  
   115  All files with these extensions and mime types are excluded from compression, 
   116  even if compression is enabled for all types.
   117  
   118  ### 5. Notes
   119  
   120  - MinIO does not support compression for Gateway (Azure/GCS/NAS) implementations.
   121  
   122  ## To test the setup
   123  
   124  To test this setup, practice put calls to the server using `mc` and use `mc ls` on 
   125  the data directory to view the size of the object.
   126  
   127  ## Explore Further
   128  
   129  - [Use `mc` with MinIO Server](https://docs.min.io/docs/minio-client-quickstart-guide)
   130  - [Use `aws-cli` with MinIO Server](https://docs.min.io/docs/aws-cli-with-minio)
   131  - [Use `s3cmd` with MinIO Server](https://docs.min.io/docs/s3cmd-with-minio)
   132  - [Use `minio-go` SDK with MinIO Server](https://docs.min.io/docs/golang-client-quickstart-guide)
   133  - [The MinIO documentation website](https://docs.min.io)