Skip to content

Commit b17bbb6

Browse files
committed
edits
1 parent 8d99216 commit b17bbb6

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

source/connect/connection-pools.txt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,24 @@ creates new connections.
3232
Create a Connection Pool
3333
------------------------
3434

35-
Every ``MongoClient`` instance has a built-in connection pool for each server
36-
in your MongoDB topology. Connection pools open sockets on demand to support
37-
concurrent MongoDB operations in your multi-threaded application.
38-
39-
The ``maxPoolSize`` option sets the maximum size of each connection pool, which
40-
defaults to 100. If the number of in-use connections to a server reaches the
41-
value of ``maxPoolSize``, the next request to that server waits until a
42-
connection becomes available.
43-
44-
Each ``MongoClient`` instance opens two more sockets per server in your MongoDB
45-
topology to monitor the server's state.
35+
Each ``MongoClient`` instance has a built-in connection pool for each server in your
36+
MongoDB topology. If you do not configure the ``minPoolSize`` option, connection
37+
pools open sockets on demand. These sockets support concurrent MongoDB
38+
operations in your application.
39+
40+
When you instantiate a new ``MongoClient``, the client opens two sockets per server
41+
in your MongoDB topology to monitor the server's state.
42+
43+
For example, a client connected to a three-node replica set opens six monitoring
44+
sockets. If the application uses the default setting for ``maxPoolSize`` and
45+
only queries the primary node, there can be at most ``106`` open
46+
sockets and ``100`` connections in the connection pool. If the application uses
47+
a :ref:`read preference <kotlin-sync-configure>` to query the secondary nodes, there
48+
can be ``306`` total connections.
49+
50+
For efficiency, create a client once for each process and reuse it for all
51+
operations. Avoid creating a new client for each request because this will
52+
increase latency.
4653

4754
Configure a Connection Pool
4855
---------------------------

0 commit comments

Comments
 (0)