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
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 :
2. Throughput :
3. Query Time :
- The compression ratio is 2X more than snappy.
- Throughput and Resource consumption is almost the same for both compression methods.
- Some inserts took more time when compared to snappy.