-
Notifications
You must be signed in to change notification settings - Fork 29
DOCSP-51416 Network Compression #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jordan-smith721
merged 5 commits into
mongodb:comp-cov
from
jordan-smith721:DOCSP-51416-compression
Jul 17, 2025
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
jordan-smith721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 2. Specify the algorithms in the ``compressors`` option of your ``Mongo::Client`` object | ||
jordan-smith721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .. 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 | ||
jordan-smith721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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 | ||
jordan-smith721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| to the ``Mongo::Client`` constructor, as shown in the following example: | ||
jordan-smith721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .. code-block:: ruby | ||
|
|
||
| client = Mongo::Client.new(["<hostname>:<port>"], | ||
| compressors: ["zlib", "snappy"]) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.