Skip to content

Commit 30f46d4

Browse files
authored
MONGOID-5649: added network compression docs (#5697)
1 parent cce6785 commit 30f46d4

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

docs/reference/configuration.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,55 @@ For more information about TLS context hooks, including best practices for
738738
assigning and removing them, see `the Ruby driver documentation <https://mongodb.com/docs/ruby-driver/current/reference/create-client/#modifying-sslcontext>`_.
739739

740740

741+
Network Compression
742+
===================
743+
744+
Mongoid supports compression of messages to and from MongoDB servers. This functionality is provided by
745+
the Ruby driver, which implements the three algorithms that are supported by MongoDB servers:
746+
747+
- `Snappy <https://google.github.io/snappy/>`_: ``snappy`` compression
748+
can be used when connecting to MongoDB servers starting with the 3.4 release,
749+
and requires the `snappy <https://rubygems.org/gems/snappy>`_ library to be
750+
installed.
751+
- `Zlib <https://zlib.net/>`_: ``zlib`` compression can be used when
752+
connecting to MongoDB servers starting with the 3.6 release.
753+
- `Zstandard <https://facebook.github.io/zstd/>`_: ``zstd`` compression can be
754+
used when connecting to MongoDB servers starting with the 4.2 release, and
755+
requires the `zstd-ruby <https://rubygems.org/gems/zstd-ruby>`_ library to
756+
be installed.
757+
758+
To use wire protocol compression, at least one compressor must be explicitly requested
759+
using either the `compressors URI option <https://www.mongodb.com/docs/manual/reference/connection-string/#mongodb-urioption-urioption.compressors>`_,
760+
or directly within the ``mongoid.yml``:
761+
762+
.. code-block:: yaml
763+
764+
development:
765+
# Configure available database clients. (required)
766+
clients:
767+
# Define the default client. (required)
768+
default:
769+
# ...
770+
options:
771+
# These options are Ruby driver options, documented in
772+
# https://mongodb.com/docs/ruby-driver/current/reference/create-client/
773+
# ...
774+
# Compressors to use. (default is to not use compression)
775+
# Valid values are zstd, zlib or snappy - or any combination of the three
776+
compressors: ["zstd", "snappy"]
777+
778+
If no compressors are explicitly requested, the driver will not use compression,
779+
even if the required dependencies for one or more compressors are present on the
780+
system.
781+
782+
The driver chooses the first compressor of the ones requested that is also supported
783+
by the server. The ``zstd`` compressor is recommended as it produces the highest
784+
compression at the same CPU consumption compared to the other compressors.
785+
786+
For maximum server compatibility all three compressors can be specified, e.g.
787+
as ``compressors: ["zstd", "snappy", "zlib"]``.
788+
789+
741790
Client-Side Encryption
742791
======================
743792

0 commit comments

Comments
 (0)