@@ -319,9 +319,8 @@ Ruby Options
319319 - none
320320
321321 * - ``:compressors``
322- - A list of potential compressors to use, in order of preference. The driver chooses the first
323- compressor that is also supported by the server. Currently the driver only supports 'snappy'
324- and 'zlib'.
322+ - A list of potential compressors to use, in order of preference.
323+ Please see below for details on how the driver implements compression.
325324 - ``Array<String>``
326325 - none
327326
@@ -740,17 +739,9 @@ URI options are explained in detail in the :manual:`Connection URI reference
740739 * - compressors=Strings
741740 - ``:compressors => Array<String>``
742741
743- Specified as a comma-separated list. The Ruby driver currently supports snappy
744- and zlib compression algorithms; the first algorithm in the list that the server
745- also supports will be used. Compression must be explicitly enabled by
746- specifying the desired compression algorithm; use "snappy,zlib" for maximum server
747- compatibility. Snappy compression requires separate installation of the
748- snappy Ruby library; if the snappy Ruby library is not available,
749- the driver raises an error during ``Mongo::Client`` creation.
750- When using MongoDB 4.0 and earlier, zlib compression is supported by the
751- server but must be manually enabled; if zlib is the only compression algorithm
752- requested (or available due to missing snappy Ruby library), 4.0 and
753- earlier servers must be configured to explicitly enable zlib compression.
742+ A comma-separated list of potential compressors to use, in order of
743+ preference. Please see below for details on how the driver implements
744+ compression.
754745
755746 * - connect=String
756747 - ``:connect => Symbol``
@@ -1665,6 +1656,40 @@ option to the client instance.
16651656 Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'test', :truncate_logs => false )
16661657
16671658
1659+ Compression
1660+ ===========
1661+
1662+ To use wire protocol compression, at least one compressor must be explicitly
1663+ requested using either the ``:compressors`` Ruby option or the ``compressors``
1664+ URI option. If no compressors are explicitly requested, the driver will not
1665+ use compression, even if the required dependencies for one or more compressors
1666+ are present on the system.
1667+
1668+ The driver chooses the first compressor of the ones requested that is also
1669+ supported by the server. The driver currently supports ``zstd``, ``snappy`` and
1670+ ``zlib`` compressors. ``zstd`` compressor is recommended as it produces
1671+ the highest compression at the same CPU consumption compared to the other
1672+ compressors. For maximum server compatibility all three compressors can be
1673+ specified, e.g. as ``compressors: ["zstd", "snappy", "zlib"]``.
1674+
1675+ ``zstd`` compressor requires the
1676+ `zstd-ruby <https://rubygems.org/gems/zstd-ruby>`_ library to be installed.
1677+ ``snappy`` compressor requires the
1678+ `snappy <https://rubygems.org/gems/snappy>`_ library to be installed.
1679+ If ``zstd`` or ``snappy`` compression is requested, and the respective
1680+ library is not loadable, the driver will raise an error during
1681+ ``Mongo::Client`` creation. ``zlib`` compression requires the ``zlib``
1682+ standard library extension to be present.
1683+
1684+ The server support for various compressors is as follows:
1685+
1686+ - ``zstd`` requires and is enabled by default in MongoDB 4.2 or higher.
1687+ - ``snappy`` requires MongoDB 3.4 or higher and is enabled by default in
1688+ MongoDB 3.6 or higher.
1689+ - ``zlib`` requires MongoDB 3.6 or higher and is enabled by default in
1690+ MongoDB 4.2 and higher.
1691+
1692+
16681693Development Configuration
16691694=========================
16701695
0 commit comments