@@ -68,33 +68,21 @@ deployment:
68
68
uri = "mongodb://localhost:27017/"
69
69
client = MongoClient(uri)
70
70
71
- Multiple Deployments
72
- --------------------
71
+ Replica Sets
72
+ ------------
73
73
74
- You can connect to multiple MongoDB deployments by specifying a list of deployments
75
- in your connection string.
74
+ To connect to a replica set, specify the hostnames (or IP addresses) and
75
+ port numbers of the replica-set members in your connection string.
76
76
77
- The following code shows how to use {+driver-short+} to connect to three deployments:
77
+ The following code shows how to use {+driver-short+} to connect to a replica set
78
+ that contains three hosts:
78
79
79
80
.. code-block:: python
80
81
81
82
from pymongo import MongoClient
82
83
83
84
client = MongoClient("mongodb://host1:27017,host2:27017,host3:27017")
84
85
85
- {+driver-short+} evenly load balances operations across the specified deployments
86
- within the specified ``localThresholdMS`` of the lowest-latency deployment. The
87
- ``localThresholdMS`` option defaults to ``15``.
88
-
89
- To learn more about how {+driver-short+} load balances operations across multiple
90
- MongoDB deployments, see the :ref:`pymongo-server-selection` guide.
91
-
92
- Replica Sets
93
- ------------
94
-
95
- To connect to a replica set, specify the hostnames (or IP addresses) and
96
- port numbers of the replica-set members in your connection string.
97
-
98
86
If you aren't able to provide a full list of hosts in the replica set, you can
99
87
specify one or more of the hosts in the replica set and instruct {+driver-short+} to
100
88
perform automatic discovery to find the others. To instruct the driver to perform
@@ -115,6 +103,13 @@ hosts, including ``host1``:
115
103
uri = "mongodb://host1:27017/?replicaSet=sampleRS"
116
104
client = MongoClient(uri)
117
105
106
+ {+driver-short+} evenly load balances operations across the specified deployments
107
+ within the specified ``localThresholdMS`` of the lowest-latency deployment. The
108
+ ``localThresholdMS`` option defaults to ``15``.
109
+
110
+ To learn more about how {+driver-short+} load balances operations across multiple
111
+ MongoDB deployments, see the :ref:`pymongo-server-selection` guide.
112
+
118
113
.. note::
119
114
120
115
The ``MongoClient`` constructor is *non-blocking*.
0 commit comments