Skip to content

Commit 235e2de

Browse files
committed
options
1 parent b2eabb3 commit 235e2de

File tree

2 files changed

+69
-152
lines changed

2 files changed

+69
-152
lines changed

source/connect/connection-options.txt

Lines changed: 69 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Network Compression
8080
* - Connection Option
8181
- Description
8282

83-
* - **compressors**
83+
* - ``compressors``
8484
- | The preferred compression types, in order, for wire-protocol messages sent to
8585
| or received from the server. The driver uses the first of these compression types
8686
| that the server supports.
@@ -90,7 +90,7 @@ Network Compression
9090
| **MongoClient Example**: ``compressors = "snappy,zstd,zlib"``
9191
| **Connection URI Example**: ``compressors=snappy,zstd,zlib``
9292

93-
* - **zlibCompressionLevel**
93+
* - ``zlibCompressionLevel``
9494
- | The compression level for zlib to use. This option accepts
9595
| an integer value between ``-1`` and ``9``:
9696
|
@@ -114,7 +114,7 @@ Timeouts
114114
* - Connection Option
115115
- Description
116116

117-
* - **timeoutMS**
117+
* - ``timeoutMS``
118118
- | The number of milliseconds each driver operation must complete within. If an
119119
| operation doesn't finish in the specified time, {+driver-short+} raises a timeout exception.
120120
| For more information, see :ref:`<pymongo-csot>`.
@@ -134,7 +134,7 @@ Server Selection
134134
* - Connection Option
135135
- Description
136136

137-
* - **server_selector**
137+
* - ``server_selector``
138138
- | A user-defined Python function called by {+driver-short+} to choose the server
139139
| to run an operation against. For more information, see
140140
| :ref:`<pymongo-server-selection>`.
@@ -147,6 +147,16 @@ Server Selection
147147
Connection Pools
148148
~~~~~~~~~~~~~~~~
149149

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+
150160
.. list-table::
151161
:widths: 30 70
152162
:header-rows: 1
@@ -155,55 +165,70 @@ Connection Pools
155165
- Description
156166

157167
* - ``connectTimeoutMS``
158-
- | Sets the time that {+driver-short+} waits when connecting a new
168+
- | The time that {+driver-short+} waits when connecting a new
159169
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``
161175

162176
* - ``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.
164178
If this limit is reached, further requests wait until a connection is established
165179
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``
167185

168186
* - ``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``
171193

172194
* - ``maxPoolSize``
173-
- | Sets the maximum number of concurrent connections that the pool maintains.
195+
- | The maximum number of concurrent connections that the pool maintains.
174196
If the maximum pool size is reached, further requests wait until a connection
175197
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``
177203

178204
* - ``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
180206
the number of open connections falls below this value due to network errors,
181207
{+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``
183213

184214
* - ``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
186216
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``
188222

189223
* - ``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
191225
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``
205231

206-
client = MongoClient("mongodb://<host>:<port>/?maxPoolSize=50")
207232
Authentication
208233
~~~~~~~~~~~~~~
209234

@@ -214,7 +239,7 @@ Authentication
214239
* - Connection Option
215240
- Description
216241

217-
* - **authMechanism**
242+
* - ``authMechanism``
218243
- | The mechanism {+driver-short+} uses to authenticate the application. Valid
219244
| options are defined in `MECHANISMS. <{+api-root+}pymongo/database.html#pymongo.auth.MECHANISMS>`__
220245
|
@@ -224,7 +249,7 @@ Authentication
224249
| **MongoClient Example**: ``authMechanism = "MONGODB-X509"``
225250
| **Connection URI Example**: ``authMechanism=MONGODB-X509``
226251

227-
* - **authMechanismProperties**
252+
* - ``authMechanismProperties``
228253
- | Options specific to the authentication mechanism. Not needed for all authentication
229254
| mechanisms.
230255
|
@@ -233,15 +258,15 @@ Authentication
233258
| **MongoClient Example**: ``authMechanismProperties = "AWS_SESSION_TOKEN:12345"``
234259
| **Connection URI Example**: ``authMechanismProperties=AWS_SESSION_TOKEN:12435``
235260

236-
* - **authSource**
261+
* - ``authSource``
237262
- | The database to authenticate against.
238263
|
239264
| **Data Type**: {+string-data-type+}
240265
| **Default**: The database in the connection URI, or ``"admin"`` if none is provided
241266
| **MongoClient Example**: ``authSource = "admin"``
242267
| **Connection URI Example**: ``authSource=admin``
243268

244-
* - **username**
269+
* - ``username``
245270
- | The username for authentication. When this option is included in a connection
246271
| URI, you must percent-escape it.
247272
|
@@ -250,7 +275,7 @@ Authentication
250275
| **MongoClient Example**: ``username = "my user"``
251276
| **Connection URI Example**: ``username=my+user``
252277

253-
* - **password**
278+
* - ``password``
254279
- | The password for authentication. When this option is included in a connection
255280
| URI, you must percent-escape it.
256281
|
@@ -271,39 +296,39 @@ Read and Write Operations
271296
* - Connection Option
272297
- Description
273298

274-
* - **replicaSet**
299+
* - ``replicaSet``
275300
- | Specifies the name of the replica set to connect to.
276301
|
277302
| **Data Type**: {+string-data-type+}
278303
| **Default**: ``null``
279304
| **MongoClient Example**: ``replicaSet='replicaSetName'``
280305
| **Connection URI Example**: ``replicaSet=replicaSetName``
281306

282-
* - **directConnection**
307+
* - ``directConnection``
283308
- | Whether to connect only to the primary member of the replica set.
284309
|
285310
| **Data Type**: {+bool-data-type+}
286311
| **Default**: ``False``
287312
| **MongoClient Example**: ``directConnection=True``
288313
| **Connection URI Example**: ``directConnection=true``
289314

290-
* - **readPreference**
315+
* - ``readPreference``
291316
- | Specifies the client's read-preference settings.
292317
|
293318
| **Data Type**: `read_preferences <{+api-root+}pymongo/read_preferences.html#pymongo.read_preferences>`__
294319
| **Default**: ``ReadPreference.Primary``
295320
| **MongoClient Example**: ``readPreference=ReadPreference.SECONDARY_PREFERRED``
296321
| **Connection URI Example**: ``readPreference=secondaryPreferred``
297322

298-
* - **readConcern**
323+
* - ``readConcern``
299324
- | Specifies the client's read-concern settings. For more information, see :manual:`</reference/read-concern/>`.
300325
|
301326
| **Data Type**: {+string-data-type+}
302327
| **Default**: ``None``
303328
| **MongoClient Example**: ``readConcern="majority"``
304329
| **Connection URI Example**: ``readConcern=majority``
305330

306-
* - **writeConcern**
331+
* - ``writeConcern``
307332
- | Specifies the client's write-concern settings. For more information, see
308333
:manual:`</reference/write-concern/>`.
309334
|
@@ -312,7 +337,7 @@ Read and Write Operations
312337
| **MongoClient Example**: ``writeConcern="majority"``
313338
| **Connection URI Example**: ``writeConcern=majority``
314339

315-
* - **localThresholdMS**
340+
* - ``localThresholdMS``
316341
- | The latency window for a replica-set members eligibility. If a member's
317342
round trip ping takes longer than the fastest server's round-trip ping
318343
time plus this value, the server isn't eligible for selection.
@@ -322,7 +347,7 @@ Read and Write Operations
322347
| **MongoClient Example**: ``localThresholdMS=35``
323348
| **Connection URI Example**: ``localThresholdMS=35``
324349

325-
* - **retryReads**
350+
* - ``retryReads``
326351
- | Specifies whether the client retries supported read operations. For more
327352
information, see :manual:`Retryable Reads </core/retryable-reads/>` in the {+mdb-server+}
328353
manual.
@@ -332,7 +357,7 @@ Read and Write Operations
332357
| **MongoClient Example**: ``retryReads=False``
333358
| **Connection URI Example**: ``retryReads=false``
334359

335-
* - **retryWrites**
360+
* - ``retryWrites``
336361
- | Specifies whether the client retries supported write operations. For more
337362
information, see :manual:`Retryable Writes </core/retryable-writes/>` in the {+mdb-server+}
338363
manual.

source/connect/connection-pools.txt

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)