Skip to content

Commit 2d216db

Browse files
committed
DOCSP-46695: Add extra info on load balancing to connection targets page (#164)
(cherry picked from commit ce4843c)
1 parent 6aacb51 commit 2d216db

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

source/connect/connection-targets.txt

Lines changed: 15 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:
@@ -74,6 +74,15 @@ Replica Sets
7474
To connect to a replica set, specify the hostnames (or IP addresses) and
7575
port numbers of the replica-set members in your connection string.
7676

77+
The following code shows how to use {+driver-short+} to connect to a replica set
78+
that contains three hosts:
79+
80+
.. code-block:: python
81+
82+
from pymongo import MongoClient
83+
84+
client = MongoClient("mongodb://host1:27017,host2:27017,host3:27017")
85+
7786
If you aren't able to provide a full list of hosts in the replica set, you can
7887
specify one or more of the hosts in the replica set and instruct {+driver-short+} to
7988
perform automatic discovery to find the others. To instruct the driver to perform
@@ -94,6 +103,11 @@ hosts, including ``host1``:
94103
uri = "mongodb://host1:27017/?replicaSet=sampleRS"
95104
client = MongoClient(uri)
96105

106+
{+driver-short+} evenly load balances operations across deployments that are reachable
107+
within the client's ``localThresholdMS`` value. To learn more about how {+driver-short+} load
108+
balances operations across multiple MongoDB deployments, see the
109+
:ref:`pymongo-server-selection` guide.
110+
97111
.. note::
98112

99113
The ``MongoClient`` constructor is *non-blocking*.

0 commit comments

Comments
 (0)