diff --git a/source/connect/connection-targets.txt b/source/connect/connection-targets.txt index 8579188a..9ee5b932 100644 --- a/source/connect/connection-targets.txt +++ b/source/connect/connection-targets.txt @@ -9,7 +9,7 @@ Choose a Connection Target :values: reference .. meta:: - :keywords: connection string, URI, server, settings, client + :keywords: connection string, URI, server, settings, client, load balancing .. contents:: On this page :local: @@ -74,6 +74,15 @@ Replica Sets To connect to a replica set, specify the hostnames (or IP addresses) and port numbers of the replica-set members in your connection string. +The following code shows how to use {+driver-short+} to connect to a replica set +that contains three hosts: + +.. code-block:: python + + from pymongo import MongoClient + + client = MongoClient("mongodb://host1:27017,host2:27017,host3:27017") + If you aren't able to provide a full list of hosts in the replica set, you can specify one or more of the hosts in the replica set and instruct {+driver-short+} to perform automatic discovery to find the others. To instruct the driver to perform @@ -94,6 +103,11 @@ hosts, including ``host1``: uri = "mongodb://host1:27017/?replicaSet=sampleRS" client = MongoClient(uri) +{+driver-short+} evenly load balances operations across deployments that are reachable +within the client's ``localThresholdMS`` value. To learn more about how {+driver-short+} load +balances operations across multiple MongoDB deployments, see the +:ref:`pymongo-server-selection` guide. + .. note:: The ``MongoClient`` constructor is *non-blocking*.