Skip to content

Commit c2f2b0c

Browse files
Kay Kimkay-kim
authored andcommitted
DOCS-11940: uri option compressors and zlibcompressionlevel
1 parent ef4fe50 commit c2f2b0c

File tree

1 file changed

+109
-47
lines changed

1 file changed

+109
-47
lines changed

source/reference/connection-string.txt

Lines changed: 109 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ The components of this string are:
5555

5656
- Required. It identifies a server
5757
address to connect to. It identifies either a hostname, IP
58-
address, or UNIX domain socket.
59-
58+
address, or UNIX domain socket.
59+
6060
.. include:: /includes/fact-uri-rs-hostnames.rst
6161

6262
For a sharded cluster, specify the hostname of the
6363
:binary:`~bin.mongos` instance.
64-
64+
6565

6666
* - ``:port1``
6767

@@ -153,7 +153,7 @@ DNS SRV record. The driver or :binary:`~bin.mongo` shell will then
153153
query the DNS for the record to determine which hosts are running the
154154
:binary:`~bin.mongod` instances.
155155

156-
.. note::
156+
.. note::
157157

158158
Use of the ``+srv`` connection string modifier
159159
automatically sets the ``ssl`` option to ``true`` for the connection.
@@ -164,9 +164,9 @@ The following example shows a typical connection string for a DNS
164164
seedlist connection string:
165165

166166
.. code-block:: none
167-
167+
168168
mongodb+srv://server.example.com/
169-
169+
170170
The corresponding DNS configuration might resemble:
171171

172172
.. code-block:: none
@@ -181,7 +181,7 @@ The corresponding DNS configuration might resemble:
181181
domain (in this example, ``example.com``) as the given hostname. If
182182
the parent domains and hostname do not match, you will not be able to
183183
connect.
184-
184+
185185
Like the standard connection string, the DNS seedlist connection string
186186
supports specifying options as a query string. With a DNS seedlist
187187
connection string, you can *also* specify the following options via a
@@ -217,14 +217,14 @@ of the DNS entry above.
217217
.. code-block:: none
218218

219219
mongodb+srv://server.example.com/?connectTimeoutMS=300000&authSource=aDifferentAuthDB
220-
220+
221221
Given the override for the ``authSource``, the equivalent connection
222222
string in the standard format would be:
223223

224224
.. code-block:: none
225225

226226
mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?connectTimeoutMS=300000&replicaSet=mySet&authSource=aDifferentAuthDB
227-
227+
228228
.. note::
229229
The ``mongodb+srv`` option will fail if there is no available DNS
230230
with records that correspond to the hostname identified in the
@@ -323,12 +323,74 @@ Connection Options
323323
timeout, though different drivers might vary. See the
324324
:ecosystem:`driver </drivers>` documentation.
325325

326+
* - .. urioption:: compressors
327+
328+
- Comma-delimited string of compressors to enable
329+
network compression for communication between this
330+
client and:
331+
332+
- a :binary:`~bin.mongod` instance
333+
334+
- a :binary:`~bin.mongos` instance.
335+
336+
You can specify the following compressors:
337+
338+
- :term:`snappy`
339+
340+
- :term:`zlib` (Available in MongoDB 3.6 or greater)
341+
342+
If you specify multiple compressors, then the order in which you list
343+
the compressors matter as well as the communication initiator. For
344+
example, if the client specifies the following network
345+
compressors ``"zlib,snappy"`` and the :binary:`~bin.mongod` specifies
346+
``"snappy,zlib"``, messages between the client and the
347+
:binary:`~bin.mongod` uses ``zlib``.
348+
349+
.. important::
350+
351+
Messages are compressed when both parties enable network
352+
compression. Otherwise, messages between the parties are
353+
uncompressed.
354+
355+
If the parties do not share at least one common compressor,
356+
messages between the parties are uncompressed.
357+
358+
359+
* - .. urioption:: zlibCompressionLevel
360+
361+
- An integer that specifies the compression level if using
362+
:term:`zlib` for :urioption:`network compression <compressors>`.
363+
364+
You can specify an integer value ranging from ``-1`` to ``9``:
365+
366+
.. list-table::
367+
:header-rows: 1
368+
:widths: 25 75
369+
370+
* - Value
371+
- Notes
372+
373+
* - ``-1``
374+
375+
- Default compression level, usually level ``6`` compression.
376+
377+
* - ``0``
378+
- No compression
379+
380+
* - ``1`` - ``9``
381+
382+
- Increasing level of compression but at the cost of speed, with:
383+
384+
- ``1`` providing the best speed but least compression, and
385+
386+
- ``9`` providing the best compression but at the slowest speed.
387+
326388
.. _connection-pool-options:
327389

328390
Connection Pool Options
329391
~~~~~~~~~~~~~~~~~~~~~~~
330392

331-
Most drivers implement some kind of connection pool handling.
393+
Most drivers implement some kind of connection pool handling.
332394
Some drivers do not support connection
333395
pools. See your :ecosystem:`driver </drivers>` documentation
334396
for more information on the connection pooling implementation. These
@@ -460,7 +522,7 @@ isolation for their reads from replica sets.
460522
* - .. urioption:: readConcernLevel
461523

462524
- The level of isolation. Can accept one of the following values:
463-
525+
464526
- :readconcern:`local <"local">`
465527
- :readconcern:`majority <"majority">`
466528
- :readconcern:`linearizable <"linearizable">`
@@ -488,8 +550,8 @@ on a per-connection basis in the connection string:
488550
* - .. urioption:: readPreference
489551

490552
- Specifies the :term:`replica set` read preference for this
491-
connection.
492-
553+
connection.
554+
493555
The read preference values are the following:
494556

495557
- :readmode:`primary`
@@ -507,33 +569,33 @@ on a per-connection basis in the connection string:
507569
.. include:: /includes/extracts/transactions-read-pref.rst
508570

509571
* - .. urioption:: maxStalenessSeconds
510-
572+
511573
- .. versionadded:: 3.4
512-
574+
513575
Specifies, in seconds, how stale a secondary can be before the client
514576
stops using it for read operations. For details, see:
515577
:ref:`replica-set-read-preference-max-staleness`.
516578

517579
By default, there is no maximum staleness and clients will not consider a
518580
secondary's lag when choosing where to direct a read operation.
519-
581+
520582
The minimum :urioption:`maxStalenessSeconds` value is 90
521583
seconds. Specifying a value between 0 and 90 seconds will produce
522584
an error. MongoDB drivers treat a ``maxStalenessSeconds`` value
523585
of ``-1`` as "no max staleness", the same as if
524586
``maxStalenessSeconds`` is omitted.
525-
587+
526588
.. important::
527589
To use ``maxStalenessSeconds``, all of the
528590
MongoDB instances in your deployment must be using MongoDB 3.4 or
529591
later. If any instances are on an earlier version of MongoDB, the
530592
driver or :binary:`~bin.mongos` will raise an error.
531-
593+
532594
The following specifies a maxStalenessSeconds value of 120 seconds
533595
with the :readmode:`secondary` read preference mode:
534-
596+
535597
.. code-block:: none
536-
598+
537599
mongodb://host.example.com/?readPreference=secondary&maxStalenessSeconds=120
538600

539601
* - .. urioption:: readPreferenceTags
@@ -615,30 +677,30 @@ Authentication Options
615677
* - .. urioption:: authMechanismProperties
616678

617679
- Specify properties for the specified :urioption:`authMechanism`
618-
as a comma-separated list of colon-separated key-value pairs.
619-
For example:
680+
as a comma-separated list of colon-separated key-value pairs.
681+
For example:
620682

621683
.. code-block:: shell
622684
:copyable: false
623685

624686
authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:true
625687

626-
The :urioption:`authMechanismProperties` option is only supported
627-
when :urioption:`authMechanism` is
688+
The :urioption:`authMechanismProperties` option is only supported
689+
when :urioption:`authMechanism` is
628690
:ref:`GSSAPI <security-auth-kerberos>`. Possible values are:
629691

630692
``SERVICE_NAME:<string>``
631693
Set the Kerberos service name when connecting to Kerberized
632694
MongoDB instances. This value must match the service name set
633-
on MongoDB instances to which you are connecting.
695+
on MongoDB instances to which you are connecting.
634696

635-
``SERVICE_NAME`` defaults to ``mongodb`` for all clients and
697+
``SERVICE_NAME`` defaults to ``mongodb`` for all clients and
636698
MongoDB instances. If you change the
637699
:parameter:`saslServiceName` setting on a MongoDB instance, you
638700
must set ``SERVICE_NAME`` to match that setting.
639701

640702
``CANONICALIZE_HOST_NAME:true|false``
641-
Canonicalize the hostname of the client host machine when
703+
Canonicalize the hostname of the client host machine when
642704
connecting to the Kerberos server. This may be required when
643705
hosts report different hostnames than what is in the Kerberos
644706
database. Defaults to ``false``.
@@ -660,10 +722,10 @@ Authentication Options
660722
must set :urioption:`gssapiServiceName` to match that setting.
661723

662724
:urioption:`gssapiServiceName` is a deprecated aliases for
663-
:urioption:`authMechanismProperties=SERVICE_NAME:mongodb
664-
<authMechanismProperties>`. For more information on which
665-
options your driver supports and their relative priority to each
666-
other, reference the documentation for your preferred driver
725+
:urioption:`authMechanismProperties=SERVICE_NAME:mongodb
726+
<authMechanismProperties>`. For more information on which
727+
options your driver supports and their relative priority to each
728+
other, reference the documentation for your preferred driver
667729
version.
668730

669731
.. _selection-discovery-options:
@@ -678,16 +740,16 @@ or write operations.
678740
.. list-table::
679741
:header-rows: 1
680742
:widths: 30 70
681-
743+
682744
* - Connection Option
683745
- Description
684-
746+
685747
* - .. urioption:: localThresholdMS
686748

687749
- The size (in milliseconds) of the latency window for selecting
688750
among multiple suitable MongoDB instances. *Default*: 15
689751
milliseconds.
690-
752+
691753
All drivers use :urioption:`localThresholdMS`. Use the
692754
``localThreshold`` alias when specifying the latency window size
693755
to :binary:`~bin.mongos`.
@@ -706,7 +768,7 @@ or write operations.
706768
error. When ``false``, the driver blocks and searches for a
707769
server up to the :urioption:`serverSelectionTimeoutMS` value.
708770
*Default*: ``true``.
709-
771+
710772
Multi-threaded drivers and :binary:`~bin.mongos` do not support
711773
:urioption:`serverSelectionTryOnce`.
712774

@@ -716,13 +778,13 @@ or write operations.
716778
checks the state of the MongoDB deployment. Specify the interval
717779
(in milliseconds) between checks, counted from the end of the
718780
previous check until the beginning of the next one.
719-
781+
720782
*Default*:
721-
783+
722784
- Single-threaded drivers: 60 seconds.
723785
- Multi-threaded drivers: 10 seconds.
724-
725-
:binary:`~bin.mongos` does not support changing the frequency of
786+
787+
:binary:`~bin.mongos` does not support changing the frequency of
726788
the heartbeat checks.
727789

728790
Miscellaneous Configuration
@@ -736,23 +798,23 @@ Miscellaneous Configuration
736798
- Description
737799

738800
* - .. urioption:: appName
739-
740-
- Specify a custom app name. The app name appears in
741-
801+
802+
- Specify a custom app name. The app name appears in
803+
742804
- :binary:`~bin.mongod` and :binary:`~bin.mongos` :doc:`logs
743805
</reference/log-messages>`,
744806

745807
- the :data:`currentOp.appName` field in the :dbcommand:`currentOp`
746808
command and :method:`db.currentOp()` method output,
747-
809+
748810
- the :data:`system.profile.appName` field in the :doc:`database
749811
profiler </reference/database-profiler>` output.
750-
812+
751813
If you do not specify a custom app name, the :binary:`~bin.mongo`
752814
shell uses the default "``MongoDB Shell``".
753-
815+
754816
.. versionadded:: 4.0
755-
817+
756818
* - .. urioption:: retryWrites
757819

758820
- Enable :ref:`retryable writes <retryable-writes>`.
@@ -830,7 +892,7 @@ UNIX Domain Socket
830892
~~~~~~~~~~~~~~~~~~
831893

832894
Use a URL encoded connection string when connecting to a UNIX domain
833-
socket.
895+
socket.
834896

835897
The following connects to a UNIX domain socket with file path
836898
``/tmp/mongodb-27017.sock``:

0 commit comments

Comments
 (0)