You can enable a driver option to compress messages which reduces the amount of data passed over the network between MongoDB and your application.
The driver supports the following algorithms:
Snappy: available in MongoDB 3.4 and later.
Zlib: available in MongoDB 3.6 and later.
Zstandard: available in MongoDB 4.2 and later.
If you specify multiple compression algorithms, the driver selects the first one in the list supported by the MongoDB instance to which it is connected.
Applications that require Snappy or Zstandard compression must add explicit dependencies for those algorithms.
Specify Compression Algorithms
You can enable compression for the connection to your MongoDB instance
by specifying the algorithms in one of two ways: adding the parameter to your
connection string using
ConnectionString or by calling the method in the
Compression Algorithm Dependencies
The JDK supports Zlib compression natively, but Snappy and Zstandard depend on open source implementations. See snappy-java and zstd-java for details.