From 7d45d175d987ed337ae94c4b691cdadff9de6322 Mon Sep 17 00:00:00 2001 From: Michael Morisi Date: Tue, 8 Jul 2025 14:56:33 -0400 Subject: [PATCH 1/5] DOCSP-51324: Network Compression --- source/connect.txt | 31 +-------- source/connect/network-compression.txt | 96 ++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 29 deletions(-) create mode 100644 source/connect/network-compression.txt diff --git a/source/connect.txt b/source/connect.txt index cc47d76d..686da4f0 100644 --- a/source/connect.txt +++ b/source/connect.txt @@ -24,7 +24,8 @@ Connection Guide Create a MongoClient Choose a Connection Target - Connection Options + Connection Options + Network Compression AWS Lambda .. /connect/connection-troubleshooting @@ -124,34 +125,6 @@ connecting by using TLS: .. To learn more about disabling hostname verification, see :ref:`kotlin-sync-insecure-tls` in .. the TLS configuration guide. -Network Compression -------------------- - -The following sections describe how to connect to MongoDB -while specifying network compression algorithms. - -Compression Algorithms -~~~~~~~~~~~~~~~~~~~~~~ - -The following tabs demonstrate how to specify all available compressors -while connecting to MongoDB: - -.. include:: /includes/connect/compression-tabs.rst - -.. To learn more about specifying compression algorithms, see -.. :ref:`kotlin-sync-enable-compression` in the Network Compression guide. - -zlib Compression Level -~~~~~~~~~~~~~~~~~~~~~~ - -The following tabs demonstrate how to specify a compression level for -the ``zlib`` compressor: - -.. include:: /includes/connect/zlib-level-tabs.rst - -.. To learn more about setting the zlib compression level, see -.. :ref:`kotlin-sync-enable-compression` in the Network Compression guide. - Server Selection ---------------- diff --git a/source/connect/network-compression.txt b/source/connect/network-compression.txt new file mode 100644 index 00000000..967dcf7b --- /dev/null +++ b/source/connect/network-compression.txt @@ -0,0 +1,96 @@ +.. _kotlin-sync-compression: + +======================== +Compress Network Traffic +======================== + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: zlib, zstandard, zstd, snappy + +Overview +-------- + +In this guide, you can learn how to use the {+driver-short+} to enable network +compression. The driver provides a connection option to compress messages, which +reduces the amount of data passed over the network between MongoDB and your application. + +The driver supports the following compression algorithms: + +- `Snappy `__ +- `Zlib `__ +- `Zstandard `__ + +If you specify multiple compression algorithms, the driver selects the first one +in the list supported by your MongoDB instance. + +.. note:: + + Applications that require Snappy or Zstandard compression must + add explicit dependencies for those algorithms. To learn more, + see the :ref:`kotlin-sync-compression-dependencies` section of this guide. + +Specify Compression Algorithms +------------------------------ + +You can enable compression for the connection to your MongoDB instance +by specifying the algorithms in one of the following ways: + +- Chain the ``compressorList()`` method to the ``MongoClientSettings.builder()`` method. +- Use the ``compressors`` parameter in your connection URI. + +The following tabs demonstrate how to specify all available compressors +while connecting to MongoDB. Select the :guilabel:`MongoClientSettings` or :guilabel:`Connection URI` +tab to see the corresponding syntax: + +.. include:: /includes/connect/compression-tabs.rst + +Specify the Zlib Compression Level +---------------------------------- + +If you specify ``zlib`` as one of your compression algorithms, you can also use the +``MongoCompressor.LEVEL`` property to specify a compression level. This option accepts +an integer value between ``-1`` and ``9``: + +- **-1:** (Default). zlib uses its default compression level (usually ``6``). +- **0:** No compression. +- **1:** Fastest speed but lowest compression. +- **9:** Best compression but slowest speed. + +The following tabs demonstrate how to specify a compression level for +the ``zlib`` compressor. Select the :guilabel:`MongoClientSettings` or :guilabel:`Connection URI` +tab to see the corresponding syntax: + +.. include:: /includes/connect/zlib-level-tabs.rst + +.. _kotlin-sync-compression-dependencies: + +Compression Algorithm Dependencies +---------------------------------- + +The JDK natively supports `Zlib `__ compression. However, +Snappy and Zstandard depend on open source Java implementations. To learn more +about these implementations, see the following GitHub repositories: + +- `snappy-java `__ +- `zstd-java `__ + +API Documentation +----------------- + +To learn more about any of the methods or types discussed in this +guide, see the following API documentation: + +- `MongoClient <{+driver-api+}/-mongo-client/index.html>`__ +- `createSnappyCompressor() <{+core-api+}/com/mongodb/MongoCompressor.html#createSnappyCompressor()>`__ +- `createZlibCompressor() <{+core-api+}/com/mongodb/MongoCompressor.html#createZlibCompressor()>`__ +- `createZstdCompressor() <{+core-api+}/com/mongodb/MongoCompressor.html#createZstdCompressor()>`__ \ No newline at end of file From b56417e25b98864c8825aa25aab3b693907acbb2 Mon Sep 17 00:00:00 2001 From: Michael Morisi Date: Tue, 8 Jul 2025 15:09:18 -0400 Subject: [PATCH 2/5] Fix --- source/connect.txt | 1 - source/connect/connection-options.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/source/connect.txt b/source/connect.txt index 686da4f0..ff9d24de 100644 --- a/source/connect.txt +++ b/source/connect.txt @@ -25,7 +25,6 @@ Connection Guide Create a MongoClient Choose a Connection Target Connection Options - Network Compression AWS Lambda .. /connect/connection-troubleshooting diff --git a/source/connect/connection-options.txt b/source/connect/connection-options.txt index 2c065e10..fa66812a 100644 --- a/source/connect/connection-options.txt +++ b/source/connect/connection-options.txt @@ -23,8 +23,8 @@ Specify Connection Options Stable API Limit Server Execution Time + Network Compression -.. /connect/network-compression .. /connect/server-selection Overview From e2ffa4ec97af6679332c614c8bfccdf7fd0317ce Mon Sep 17 00:00:00 2001 From: Michael Morisi Date: Tue, 8 Jul 2025 15:28:01 -0400 Subject: [PATCH 3/5] Fix links --- source/connect/network-compression.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/connect/network-compression.txt b/source/connect/network-compression.txt index 967dcf7b..db66e121 100644 --- a/source/connect/network-compression.txt +++ b/source/connect/network-compression.txt @@ -91,6 +91,6 @@ To learn more about any of the methods or types discussed in this guide, see the following API documentation: - `MongoClient <{+driver-api+}/-mongo-client/index.html>`__ -- `createSnappyCompressor() <{+core-api+}/com/mongodb/MongoCompressor.html#createSnappyCompressor()>`__ -- `createZlibCompressor() <{+core-api+}/com/mongodb/MongoCompressor.html#createZlibCompressor()>`__ -- `createZstdCompressor() <{+core-api+}/com/mongodb/MongoCompressor.html#createZstdCompressor()>`__ \ No newline at end of file +- `createSnappyCompressor() <{+core-api+}/MongoCompressor.html#createSnappyCompressor()>`__ +- `createZlibCompressor() <{+core-api+}/MongoCompressor.html#createZlibCompressor()>`__ +- `createZstdCompressor() <{+core-api+}/MongoCompressor.html#createZstdCompressor()>`__ \ No newline at end of file From 114808972431ecc7141fb176fe63c3ea947dad27 Mon Sep 17 00:00:00 2001 From: Michael Morisi Date: Wed, 9 Jul 2025 10:58:22 -0400 Subject: [PATCH 4/5] MB feedback --- snooty.toml | 1 + source/connect/connection-options.txt | 6 +++--- source/connect/{ => connection-options}/csot.txt | 0 .../network-compression.txt | 14 +++++++------- .../{ => connection-options}/stable-api.txt | 0 5 files changed, 11 insertions(+), 10 deletions(-) rename source/connect/{ => connection-options}/csot.txt (100%) rename source/connect/{ => connection-options}/network-compression.txt (88%) rename source/connect/{ => connection-options}/stable-api.txt (100%) diff --git a/snooty.toml b/snooty.toml index 1f20e7e9..82828f5f 100644 --- a/snooty.toml +++ b/snooty.toml @@ -16,6 +16,7 @@ toc_landing_pages = [ "/data-formats", "/builders", "/aggregation", + "/connection-options" ] sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/" diff --git a/source/connect/connection-options.txt b/source/connect/connection-options.txt index fa66812a..2c58b381 100644 --- a/source/connect/connection-options.txt +++ b/source/connect/connection-options.txt @@ -21,9 +21,9 @@ Specify Connection Options :titlesonly: :maxdepth: 1 - Stable API - Limit Server Execution Time - Network Compression + Stable API + Limit Server Execution Time + Network Compression .. /connect/server-selection diff --git a/source/connect/csot.txt b/source/connect/connection-options/csot.txt similarity index 100% rename from source/connect/csot.txt rename to source/connect/connection-options/csot.txt diff --git a/source/connect/network-compression.txt b/source/connect/connection-options/network-compression.txt similarity index 88% rename from source/connect/network-compression.txt rename to source/connect/connection-options/network-compression.txt index db66e121..4387b9be 100644 --- a/source/connect/network-compression.txt +++ b/source/connect/connection-options/network-compression.txt @@ -48,7 +48,7 @@ by specifying the algorithms in one of the following ways: - Chain the ``compressorList()`` method to the ``MongoClientSettings.builder()`` method. - Use the ``compressors`` parameter in your connection URI. -The following tabs demonstrate how to specify all available compressors +The following examples demonstrate how to specify all available compressors while connecting to MongoDB. Select the :guilabel:`MongoClientSettings` or :guilabel:`Connection URI` tab to see the corresponding syntax: @@ -61,12 +61,12 @@ If you specify ``zlib`` as one of your compression algorithms, you can also use ``MongoCompressor.LEVEL`` property to specify a compression level. This option accepts an integer value between ``-1`` and ``9``: -- **-1:** (Default). zlib uses its default compression level (usually ``6``). -- **0:** No compression. -- **1:** Fastest speed but lowest compression. -- **9:** Best compression but slowest speed. +- **-1:** Default compression (usually ``6``) +- **0:** No compression +- **1:** Fastest speed but lowest compression +- **9:** Best compression but slowest speed -The following tabs demonstrate how to specify a compression level for +The following examples demonstrate how to specify a compression level for the ``zlib`` compressor. Select the :guilabel:`MongoClientSettings` or :guilabel:`Connection URI` tab to see the corresponding syntax: @@ -82,7 +82,7 @@ Snappy and Zstandard depend on open source Java implementations. To learn more about these implementations, see the following GitHub repositories: - `snappy-java `__ -- `zstd-java `__ +- `zstd-jni `__ API Documentation ----------------- diff --git a/source/connect/stable-api.txt b/source/connect/connection-options/stable-api.txt similarity index 100% rename from source/connect/stable-api.txt rename to source/connect/connection-options/stable-api.txt From e2f8838d382a3fa7be057148b4944d6c5bbe8e26 Mon Sep 17 00:00:00 2001 From: Michael Morisi Date: Wed, 9 Jul 2025 11:11:08 -0400 Subject: [PATCH 5/5] Fix --- snooty.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snooty.toml b/snooty.toml index 82828f5f..9a3bf375 100644 --- a/snooty.toml +++ b/snooty.toml @@ -16,7 +16,7 @@ toc_landing_pages = [ "/data-formats", "/builders", "/aggregation", - "/connection-options" + "/connect/connection-options" ] sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"