Skip to content

Commit 9ab3350

Browse files
committed
DOCSP-46695: Add extra info on load balancing to connection targets page
1 parent ee3bc3a commit 9ab3350

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

source/connect/connection-targets.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Choose a Connection Target
99
:values: reference
1010

1111
.. meta::
12-
:keywords: connection string, URI, server, settings, client
12+
:keywords: connection string, URI, server, settings, client, load balancing
1313

1414
.. contents:: On this page
1515
:local:
@@ -68,6 +68,28 @@ deployment:
6868
uri = "mongodb://localhost:27017/"
6969
client = MongoClient(uri)
7070

71+
Multiple Deployments
72+
--------------------
73+
74+
You can connect to multiple MongoDB deployments by specifying a list of ``mongos``
75+
servers in your connection string.
76+
77+
The following code shows how to use {+driver-short+} to connect to three ``mongos``
78+
instances:
79+
80+
.. code-block:: python
81+
82+
from pymongo import MongoClient
83+
84+
client = MongoClient("mongodb://host1:27017,host2:27017,host3:27017")
85+
86+
{+driver-short+} evenly load balances operations across the specified ``mongos`` instances
87+
within the specified ``localThresholdMS`` of the lowest-latency ``mongos`` instance. The
88+
``localThresholdMS`` option defaults to ``15``.
89+
90+
To learn more about how {+driver-short+} load balances operations across multiple
91+
``mongos`` instances, see the :ref:`pymongo-server-selection` guide.
92+
7193
Replica Sets
7294
------------
7395

0 commit comments

Comments
 (0)