@@ -80,7 +80,7 @@ Network Compression
80
80
* - Connection Option
81
81
- Description
82
82
83
- * - ** compressors**
83
+ * - `` compressors``
84
84
- | The preferred compression types, in order, for wire-protocol messages sent to
85
85
| or received from the server. The driver uses the first of these compression types
86
86
| that the server supports.
@@ -90,7 +90,7 @@ Network Compression
90
90
| **MongoClient Example**: ``compressors = "snappy,zstd,zlib"``
91
91
| **Connection URI Example**: ``compressors=snappy,zstd,zlib``
92
92
93
- * - ** zlibCompressionLevel**
93
+ * - `` zlibCompressionLevel``
94
94
- | The compression level for zlib to use. This option accepts
95
95
| an integer value between ``-1`` and ``9``:
96
96
|
@@ -114,7 +114,7 @@ Timeouts
114
114
* - Connection Option
115
115
- Description
116
116
117
- * - ** timeoutMS**
117
+ * - `` timeoutMS``
118
118
- | The number of milliseconds each driver operation must complete within. If an
119
119
| operation doesn't finish in the specified time, {+driver-short+} raises a timeout exception.
120
120
| For more information, see :ref:`<pymongo-csot>`.
@@ -134,7 +134,7 @@ Server Selection
134
134
* - Connection Option
135
135
- Description
136
136
137
- * - ** server_selector**
137
+ * - `` server_selector``
138
138
- | A user-defined Python function called by {+driver-short+} to choose the server
139
139
| to run an operation against. For more information, see
140
140
| :ref:`<pymongo-server-selection>`.
@@ -147,6 +147,16 @@ Server Selection
147
147
Connection Pools
148
148
~~~~~~~~~~~~~~~~
149
149
150
+ A **connection pool** is a cache of open database connections maintained by {+driver-short+}.
151
+ When your application requests a connection to MongoDB, {+driver-short+} seamlessly
152
+ gets a connection from the pool, performs operations, and returns the connection
153
+ to the pool for reuse. Connection pools help reduce application latency and the number
154
+ of times new connections are created by {+driver-short+}.
155
+
156
+ To learn more about connection pools, see
157
+ :manual:`Connection Pool Overview </administration/connection-pool-overview/>`
158
+ in the {+mdb-server+} manual.
159
+
150
160
.. list-table::
151
161
:widths: 30 70
152
162
:header-rows: 1
@@ -155,55 +165,70 @@ Connection Pools
155
165
- Description
156
166
157
167
* - ``connectTimeoutMS``
158
- - | Sets the time that {+driver-short+} waits when connecting a new
168
+ - | The time that {+driver-short+} waits when connecting a new
159
169
socket before timing out.
160
- | Defaults to ``20000``
170
+ |
171
+ | **Data Type**: ``int``
172
+ | **Default**: ``20000``
173
+ | **MongoClient Example**: ``connectTimeoutMS = 40000``
174
+ | **Connection URI Example**: ``connectTimeoutMS=40000``
161
175
162
176
* - ``maxConnecting``
163
- - | Sets the maximum number of connections that each pool can establish concurrently.
177
+ - | The maximum number of connections that each pool can establish concurrently.
164
178
If this limit is reached, further requests wait until a connection is established
165
179
or another in-use connection is checked back into the pool.
166
- | Defaults to ``2``
180
+ |
181
+ | **Data Type**: ``int``
182
+ | **Default**: ``2``
183
+ | **MongoClient Example**: ``maxConnecting = 3``
184
+ | **Connection URI Example**: ``maxConnecting=3``
167
185
168
186
* - ``maxIdleTimeMS``
169
- - | Sets the maximum time that a connection can remain idle in the pool.
170
- | Defaults to ``None`` (no limit)
187
+ - | The maximum time that a connection can remain idle in the pool.
188
+ |
189
+ | **Data Type**: ``int``
190
+ | **Default**: ``None`` (no limit)
191
+ | **MongoClient Example**: ``maxIdleTimeMS = 60000``
192
+ | **Connection URI Example**: ``maxIdleTimeMS=60000``
171
193
172
194
* - ``maxPoolSize``
173
- - | Sets the maximum number of concurrent connections that the pool maintains.
195
+ - | The maximum number of concurrent connections that the pool maintains.
174
196
If the maximum pool size is reached, further requests wait until a connection
175
197
becomes available.
176
- | Defaults to ``100``
198
+ |
199
+ | **Data Type**: ``int``
200
+ | **Default**: ``100``
201
+ | **MongoClient Example**: ``maxPoolSize = 150``
202
+ | **Connection URI Example**: ``maxPoolSize=150``
177
203
178
204
* - ``minPoolSize``
179
- - | Sets the minimum number of concurrent connections that the pool maintains. If
205
+ - | The minimum number of concurrent connections that the pool maintains. If
180
206
the number of open connections falls below this value due to network errors,
181
207
{+driver-short+} attempts to create new connections to maintain this minimum.
182
- | Defaults to ``0``
208
+ |
209
+ | **Data Type**: ``int``
210
+ | **Default**: ``0``
211
+ | **MongoClient Example**: ``minPoolSize = 3``
212
+ | **Connection URI Example**: ``minPoolSize=3``
183
213
184
214
* - ``socketTimeoutMS``
185
- - | Sets the length of time that {+driver-short+} waits for a response from the server
215
+ - | The length of time that {+driver-short+} waits for a response from the server
186
216
before timing out.
187
- | Defaults to ``None`` (no timeout)
217
+ |
218
+ | **Data Type**: ``int``
219
+ | **Default**: ``None`` (no timeout)
220
+ | **MongoClient Example**: ``socketTimeoutMS = 100000``
221
+ | **Connection URI Example**: ``socketTimeoutMS=100000``
188
222
189
223
* - ``waitQueueTimeoutMS``
190
- - | Sets how long a thread waits for a connection to become available in the connection pool
224
+ - | How long a thread waits for a connection to become available in the connection pool
191
225
before timing out.
192
- | Defaults to ``None`` (no timeout)
193
-
194
- The following code creates a client with a maximum connection pool size of ``50`` by using the
195
- ``maxPoolSize`` parameter:
196
-
197
- .. code-block:: python
198
-
199
- client = MongoClient(host, port, maxPoolSize=50)
200
-
201
- The following code creates a client with the same configuration as the preceding example,
202
- but uses a connection URI:
203
-
204
- .. code-block:: python
226
+ |
227
+ | **Data Type**: ``int``
228
+ | **Default**: ``None`` (no timeout)
229
+ | **MongoClient Example**: ``waitQueueTimeoutMS = 100000``
230
+ | **Connection URI Example**: ``waitQueueTimeoutMS=100000``
205
231
206
- client = MongoClient("mongodb://<host>:<port>/?maxPoolSize=50")
207
232
Authentication
208
233
~~~~~~~~~~~~~~
209
234
@@ -214,7 +239,7 @@ Authentication
214
239
* - Connection Option
215
240
- Description
216
241
217
- * - ** authMechanism**
242
+ * - `` authMechanism``
218
243
- | The mechanism {+driver-short+} uses to authenticate the application. Valid
219
244
| options are defined in `MECHANISMS. <{+api-root+}pymongo/database.html#pymongo.auth.MECHANISMS>`__
220
245
|
@@ -224,7 +249,7 @@ Authentication
224
249
| **MongoClient Example**: ``authMechanism = "MONGODB-X509"``
225
250
| **Connection URI Example**: ``authMechanism=MONGODB-X509``
226
251
227
- * - ** authMechanismProperties**
252
+ * - `` authMechanismProperties``
228
253
- | Options specific to the authentication mechanism. Not needed for all authentication
229
254
| mechanisms.
230
255
|
@@ -233,15 +258,15 @@ Authentication
233
258
| **MongoClient Example**: ``authMechanismProperties = "AWS_SESSION_TOKEN:12345"``
234
259
| **Connection URI Example**: ``authMechanismProperties=AWS_SESSION_TOKEN:12435``
235
260
236
- * - ** authSource**
261
+ * - `` authSource``
237
262
- | The database to authenticate against.
238
263
|
239
264
| **Data Type**: {+string-data-type+}
240
265
| **Default**: The database in the connection URI, or ``"admin"`` if none is provided
241
266
| **MongoClient Example**: ``authSource = "admin"``
242
267
| **Connection URI Example**: ``authSource=admin``
243
268
244
- * - ** username**
269
+ * - `` username``
245
270
- | The username for authentication. When this option is included in a connection
246
271
| URI, you must percent-escape it.
247
272
|
@@ -250,7 +275,7 @@ Authentication
250
275
| **MongoClient Example**: ``username = "my user"``
251
276
| **Connection URI Example**: ``username=my+user``
252
277
253
- * - ** password**
278
+ * - `` password``
254
279
- | The password for authentication. When this option is included in a connection
255
280
| URI, you must percent-escape it.
256
281
|
@@ -271,39 +296,39 @@ Read and Write Operations
271
296
* - Connection Option
272
297
- Description
273
298
274
- * - ** replicaSet**
299
+ * - `` replicaSet``
275
300
- | Specifies the name of the replica set to connect to.
276
301
|
277
302
| **Data Type**: {+string-data-type+}
278
303
| **Default**: ``null``
279
304
| **MongoClient Example**: ``replicaSet='replicaSetName'``
280
305
| **Connection URI Example**: ``replicaSet=replicaSetName``
281
306
282
- * - ** directConnection**
307
+ * - `` directConnection``
283
308
- | Whether to connect only to the primary member of the replica set.
284
309
|
285
310
| **Data Type**: {+bool-data-type+}
286
311
| **Default**: ``False``
287
312
| **MongoClient Example**: ``directConnection=True``
288
313
| **Connection URI Example**: ``directConnection=true``
289
314
290
- * - ** readPreference**
315
+ * - `` readPreference``
291
316
- | Specifies the client's read-preference settings.
292
317
|
293
318
| **Data Type**: `read_preferences <{+api-root+}pymongo/read_preferences.html#pymongo.read_preferences>`__
294
319
| **Default**: ``ReadPreference.Primary``
295
320
| **MongoClient Example**: ``readPreference=ReadPreference.SECONDARY_PREFERRED``
296
321
| **Connection URI Example**: ``readPreference=secondaryPreferred``
297
322
298
- * - ** readConcern**
323
+ * - `` readConcern``
299
324
- | Specifies the client's read-concern settings. For more information, see :manual:`</reference/read-concern/>`.
300
325
|
301
326
| **Data Type**: {+string-data-type+}
302
327
| **Default**: ``None``
303
328
| **MongoClient Example**: ``readConcern="majority"``
304
329
| **Connection URI Example**: ``readConcern=majority``
305
330
306
- * - ** writeConcern**
331
+ * - `` writeConcern``
307
332
- | Specifies the client's write-concern settings. For more information, see
308
333
:manual:`</reference/write-concern/>`.
309
334
|
@@ -312,7 +337,7 @@ Read and Write Operations
312
337
| **MongoClient Example**: ``writeConcern="majority"``
313
338
| **Connection URI Example**: ``writeConcern=majority``
314
339
315
- * - ** localThresholdMS**
340
+ * - `` localThresholdMS``
316
341
- | The latency window for a replica-set members eligibility. If a member's
317
342
round trip ping takes longer than the fastest server's round-trip ping
318
343
time plus this value, the server isn't eligible for selection.
@@ -322,7 +347,7 @@ Read and Write Operations
322
347
| **MongoClient Example**: ``localThresholdMS=35``
323
348
| **Connection URI Example**: ``localThresholdMS=35``
324
349
325
- * - ** retryReads**
350
+ * - `` retryReads``
326
351
- | Specifies whether the client retries supported read operations. For more
327
352
information, see :manual:`Retryable Reads </core/retryable-reads/>` in the {+mdb-server+}
328
353
manual.
@@ -332,7 +357,7 @@ Read and Write Operations
332
357
| **MongoClient Example**: ``retryReads=False``
333
358
| **Connection URI Example**: ``retryReads=false``
334
359
335
- * - ** retryWrites**
360
+ * - `` retryWrites``
336
361
- | Specifies whether the client retries supported write operations. For more
337
362
information, see :manual:`Retryable Writes </core/retryable-writes/>` in the {+mdb-server+}
338
363
manual.
0 commit comments