@@ -7,7 +7,7 @@ Specify Connection Options
77.. contents:: On this page
88 :local:
99 :backlinks: none
10- :depth: 1
10+ :depth: 2
1111 :class: singlecol
1212
1313.. facet::
@@ -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>`.
@@ -144,6 +144,91 @@ Server Selection
144144 | **MongoClient Example**: ``server_selector = your_function``
145145 | **Connection URI Example**: N/A
146146
147+ Connection Pools
148+ ~~~~~~~~~~~~~~~~
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+}
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 that {+driver-short+} must create new connections.
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+
160+ .. list-table::
161+ :widths: 30 70
162+ :header-rows: 1
163+
164+ * - Setting
165+ - Description
166+
167+ * - ``connectTimeoutMS``
168+ - | The time that {+driver-short+} waits when connecting a new
169+ socket before timing out.
170+ |
171+ | **Data Type**: ``int``
172+ | **Default**: ``20000``
173+ | **MongoClient Example**: ``connectTimeoutMS = 40000``
174+ | **Connection URI Example**: ``connectTimeoutMS=40000``
175+
176+ * - ``maxConnecting``
177+ - | The maximum number of connections that each pool can establish concurrently.
178+ If this limit is reached, further requests wait until a connection is established
179+ or another in-use connection is checked back into the pool.
180+ |
181+ | **Data Type**: ``int``
182+ | **Default**: ``2``
183+ | **MongoClient Example**: ``maxConnecting = 3``
184+ | **Connection URI Example**: ``maxConnecting=3``
185+
186+ * - ``maxIdleTimeMS``
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``
193+
194+ * - ``maxPoolSize``
195+ - | The maximum number of concurrent connections that the pool maintains.
196+ If the maximum pool size is reached, further requests wait until a connection
197+ becomes available.
198+ |
199+ | **Data Type**: ``int``
200+ | **Default**: ``100``
201+ | **MongoClient Example**: ``maxPoolSize = 150``
202+ | **Connection URI Example**: ``maxPoolSize=150``
203+
204+ * - ``minPoolSize``
205+ - | The minimum number of concurrent connections that the pool maintains. If
206+ the number of open connections falls below this value due to network errors,
207+ {+driver-short+} attempts to create new connections to maintain this minimum.
208+ |
209+ | **Data Type**: ``int``
210+ | **Default**: ``0``
211+ | **MongoClient Example**: ``minPoolSize = 3``
212+ | **Connection URI Example**: ``minPoolSize=3``
213+
214+ * - ``socketTimeoutMS``
215+ - | The length of time that {+driver-short+} waits for a response from the server
216+ before timing out.
217+ |
218+ | **Data Type**: ``int``
219+ | **Default**: ``None`` (no timeout)
220+ | **MongoClient Example**: ``socketTimeoutMS = 100000``
221+ | **Connection URI Example**: ``socketTimeoutMS=100000``
222+
223+ * - ``waitQueueTimeoutMS``
224+ - | How long a thread waits for a connection to become available in the connection pool
225+ before timing out.
226+ |
227+ | **Data Type**: ``int``
228+ | **Default**: ``None`` (no timeout)
229+ | **MongoClient Example**: ``waitQueueTimeoutMS = 100000``
230+ | **Connection URI Example**: ``waitQueueTimeoutMS=100000``
231+
147232Authentication
148233~~~~~~~~~~~~~~
149234
@@ -154,7 +239,7 @@ Authentication
154239 * - Connection Option
155240 - Description
156241
157- * - ** authMechanism**
242+ * - `` authMechanism``
158243 - | The mechanism {+driver-short+} uses to authenticate the application. Valid
159244 | options are defined in `MECHANISMS. <{+api-root+}pymongo/database.html#pymongo.auth.MECHANISMS>`__
160245 |
@@ -164,7 +249,7 @@ Authentication
164249 | **MongoClient Example**: ``authMechanism = "MONGODB-X509"``
165250 | **Connection URI Example**: ``authMechanism=MONGODB-X509``
166251
167- * - ** authMechanismProperties**
252+ * - `` authMechanismProperties``
168253 - | Options specific to the authentication mechanism. Not needed for all authentication
169254 | mechanisms.
170255 |
@@ -173,15 +258,15 @@ Authentication
173258 | **MongoClient Example**: ``authMechanismProperties = "AWS_SESSION_TOKEN:12345"``
174259 | **Connection URI Example**: ``authMechanismProperties=AWS_SESSION_TOKEN:12435``
175260
176- * - ** authSource**
261+ * - `` authSource``
177262 - | The database to authenticate against.
178263 |
179264 | **Data Type**: {+string-data-type+}
180265 | **Default**: The database in the connection URI, or ``"admin"`` if none is provided
181266 | **MongoClient Example**: ``authSource = "admin"``
182267 | **Connection URI Example**: ``authSource=admin``
183268
184- * - ** username**
269+ * - `` username``
185270 - | The username for authentication. When this option is included in a connection
186271 | URI, you must percent-escape it.
187272 |
@@ -190,7 +275,7 @@ Authentication
190275 | **MongoClient Example**: ``username = "my user"``
191276 | **Connection URI Example**: ``username=my+user``
192277
193- * - ** password**
278+ * - `` password``
194279 - | The password for authentication. When this option is included in a connection
195280 | URI, you must percent-escape it.
196281 |
@@ -211,39 +296,39 @@ Read and Write Operations
211296 * - Connection Option
212297 - Description
213298
214- * - ** replicaSet**
299+ * - `` replicaSet``
215300 - | Specifies the name of the replica set to connect to.
216301 |
217302 | **Data Type**: {+string-data-type+}
218303 | **Default**: ``null``
219304 | **MongoClient Example**: ``replicaSet='replicaSetName'``
220305 | **Connection URI Example**: ``replicaSet=replicaSetName``
221306
222- * - ** directConnection**
307+ * - `` directConnection``
223308 - | Whether to connect only to the primary member of the replica set.
224309 |
225310 | **Data Type**: {+bool-data-type+}
226311 | **Default**: ``False``
227312 | **MongoClient Example**: ``directConnection=True``
228313 | **Connection URI Example**: ``directConnection=true``
229314
230- * - ** readPreference**
315+ * - `` readPreference``
231316 - | Specifies the client's read-preference settings.
232317 |
233318 | **Data Type**: `read_preferences <{+api-root+}pymongo/read_preferences.html#pymongo.read_preferences>`__
234319 | **Default**: ``ReadPreference.Primary``
235320 | **MongoClient Example**: ``readPreference=ReadPreference.SECONDARY_PREFERRED``
236321 | **Connection URI Example**: ``readPreference=secondaryPreferred``
237322
238- * - ** readConcern**
323+ * - `` readConcern``
239324 - | Specifies the client's read-concern settings. For more information, see :manual:`</reference/read-concern/>`.
240325 |
241326 | **Data Type**: {+string-data-type+}
242327 | **Default**: ``None``
243328 | **MongoClient Example**: ``readConcern="majority"``
244329 | **Connection URI Example**: ``readConcern=majority``
245330
246- * - ** writeConcern**
331+ * - `` writeConcern``
247332 - | Specifies the client's write-concern settings. For more information, see
248333 :manual:`</reference/write-concern/>`.
249334 |
@@ -252,7 +337,7 @@ Read and Write Operations
252337 | **MongoClient Example**: ``writeConcern="majority"``
253338 | **Connection URI Example**: ``writeConcern=majority``
254339
255- * - ** localThresholdMS**
340+ * - `` localThresholdMS``
256341 - | The latency window for a replica-set members eligibility. If a member's
257342 round trip ping takes longer than the fastest server's round-trip ping
258343 time plus this value, the server isn't eligible for selection.
@@ -262,7 +347,7 @@ Read and Write Operations
262347 | **MongoClient Example**: ``localThresholdMS=35``
263348 | **Connection URI Example**: ``localThresholdMS=35``
264349
265- * - ** retryReads**
350+ * - `` retryReads``
266351 - | Specifies whether the client retries supported read operations. For more
267352 information, see :manual:`Retryable Reads </core/retryable-reads/>` in the {+mdb-server+}
268353 manual.
@@ -272,7 +357,7 @@ Read and Write Operations
272357 | **MongoClient Example**: ``retryReads=False``
273358 | **Connection URI Example**: ``retryReads=false``
274359
275- * - ** retryWrites**
360+ * - `` retryWrites``
276361 - | Specifies whether the client retries supported write operations. For more
277362 information, see :manual:`Retryable Writes </core/retryable-writes/>` in the {+mdb-server+}
278363 manual.
0 commit comments