Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions snooty.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name = "ruby-driver"
title = "Ruby Driver"
toc_landing_pages = [
"connect/connection-options",
"/crud/query",
"/indexes",
"/security/authentication"
Expand Down
3 changes: 0 additions & 3 deletions source/connect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ Connect to MongoDB
:maxdepth: 1

Create a Client </connect/mongoclient>
Stable API </connect/stable-api>
Choose a Connection Target </connect/connection-targets>
Connection Options </connect/connection-options>
Configure TLS </connect/tls>
Limit Server Execution Time </connect/csot>
AWS Lambda <https://www.mongodb.com/docs/atlas/manage-connections-aws-lambda/>
8 changes: 8 additions & 0 deletions source/connect/connection-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ Specify Connection Options
.. meta::
:keywords: connection string, URI, server, Atlas, settings, configure

.. toctree::
:titlesonly:
:maxdepth: 1

Compress Network Traffic </connect/network-compression>
Stable API </connect/stable-api>
Limit Server Execution Time </connect/csot>

Overview
--------

Expand Down
61 changes: 61 additions & 0 deletions source/connect/network-compression.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
========================
Compress Network Traffic
========================

.. meta::
:keywords: network compression, zlib, snappy, zstd, Ruby driver, connection string, URI, settings, configure

.. contents:: On this page
:local:
:depth: 2

Overview
--------

The {+driver-short+} supports network compression to reduce the amount
of data transmitted between the client and the server.

The driver supports the following compression algorithms:

1. `Snappy <https://google.github.io/snappy/>`__

2. `Zlib <https://zlib.net/>`__

3. `Zstandard <https://github.com/facebook/zstd/>`__


If you specify multiple compression algorithms, the driver selects the first
one in the list supported by your MongoDB instance.

Specify Connection Algorithms
-----------------------------

To enable compression for the connection to your MongoDB instance,
specify the algorithms you want to use in one of the following ways:

1. Add the algorithms to your connection string as a parameter
2. Specify the algorithms in the ``compressors`` option of your ``Mongo::Client`` object

.. tabs::

.. tab:: Connection String
:tabid: connection-string

To enable network compression by using the connection string, add the ``compressors`` option.
You can specify one or more algorithms as a comma-separated list.

.. code-block:: ruby

uri = "mongodb://<hostname>:<port>/?compressors=zlib,snappy"
client = Mongo::Client.new(uri)

.. tab:: Client Settings
:tabid: client-settings

To enable compression in your Client object, pass the ``:compressors`` option
to the ``Mongo::Client`` constructor, as shown in the following example:

.. code-block:: ruby

client = Mongo::Client.new(["<hostname>:<port>"],
compressors: ["zlib", "snappy"])
Loading