Blog
>
Technology

Compression Snappy or Zstd ?

Ajith Kumar
I
July 12, 2021
I
Image Courtesy - MongoDB

Before 4.2, MongoDB supports two types of compression.

1. Snappy(Default) --- > Less compression ratio compared to Zlip / less resource consumption

2. Zlib  --- > High compression (like gzip) / high resorce consumption

After 4.2

Zstd compression is a new feature in MongoDB 4.2. To put this in context, this is the third compression option supported by MongoDB. MongoDB already has support for snappy and Zlib compression of data.

Snappy is the current default compression used by the Wired Tiger storage engine for block and journal compression and also by the MongoDB server for client communications.

Compression is a tradeoff between how much CPU is used to perform the compression post data insertion and how much that CPU works results in more compressed data. Snappy is very much the baseline for modern compression.

The older alternative Zlib compressor uses more CPU but can more effectively compress data. It has been available for MongoDB users who were prepared to accept that trade-off.

Zstandard, referred to as zstd, is a more modern compressor that offers higher compression rates while using less CPU compared to other compression algorithms. MongoDB 4.2 will continue to use snappy compression by default.

Here, we have tested the compression with the following configurations,

Host config : 2vCPU, 4 GB RAM

Data Size: 225868850829

1.Disk usage :

No alt text provided for this image

2. Throughput :

No alt text provided for this image

3. Query Time :

No alt text provided for this image

Pros :

  • The compression ratio is 2X more than snappy.
  • Throughput and Resource consumption is almost the same for both compression methods.

Cons :

  • Some inserts took more time when compared to snappy.

Database
MongoDB

About Quinbay

Quinbay is a dynamic one stop technology company driven by the passion to disrupt technology today and define the future.
We private label and create digital future tech platforms for you.

Digitized . Automated . Intelligent