@@ -40,8 +40,8 @@ pools open sockets on demand. These sockets support concurrent MongoDB
40
40
operations, or `goroutines <https://go.dev/tour/concurrency/1>`__, in
41
41
your application.
42
42
43
- Each ``Client`` instance opens two more sockets per server in your MongoDB
44
- topology for monitoring the server's state.
43
+ When a new ``Client`` instance is instatiated, it opens two sockets per server
44
+ in your MongoDB topology for monitoring the server's state.
45
45
46
46
For example, a client connected to a three-node replica set opens six monitoring
47
47
sockets. If the application uses the default setting for ``maxPoolSize`` and
@@ -50,8 +50,9 @@ sockets and ``100`` connections in the connection pool. If the application uses
50
50
a :ref:`read preference <golang-read-pref>` to query the secondary nodes, their
51
51
pools also grow and there can be ``306`` total connections.
52
52
53
- Create a client once for each process, and reuse it for all operations. Avoid
54
- creating a new client for each request, as this is inefficient.
53
+ For efficiency, create a client once for each process, and reuse it for all
54
+ operations. Avoid creating a new client for each request because this will
55
+ increase latency.
55
56
56
57
Configure a Connection Pool
57
58
---------------------------
@@ -105,6 +106,9 @@ connection pool:
105
106
106
107
*Default*: ``0`` (no limit)
107
108
109
+ Example
110
+ ~~~~~~~
111
+
108
112
The following code creates a client with a maximum connection pool size of
109
113
``50``, a minimum pool size of ``10``, and a maximum idle time of
110
114
``30000`` milliseconds (30 seconds):
@@ -128,9 +132,9 @@ Any new goroutine stops waiting in the following cases:
128
132
on connection creation.
129
133
130
134
The driver does not limit the number of operations that can wait for sockets to
131
- become available and it is the application's responsibility to limit the size of
132
- its pool to bound queuing during a load spike . Operations can wait for any length of time
133
- unless you define the ``waitQueueTimeoutMS`` option.
135
+ become available, so it is the application's responsibility to manage its
136
+ operation queue . Operations can wait for any length of time unless you define
137
+ the ``waitQueueTimeoutMS`` option.
134
138
135
139
An operation that waits more than the length of time defined by
136
140
``waitQueueTimeoutMS`` for a socket raises a connection error. Use this option
@@ -141,7 +145,7 @@ Disconnecting
141
145
-------------
142
146
143
147
When you call ``Client.Disconnect()`` from any goroutine, the driver closes all
144
- idle sockets and closes all sockets in use as they are returned to the pool.
148
+ idle sockets, and then closes all sockets as they are returned to the pool.
145
149
146
150
Additional Information
147
151
----------------------
0 commit comments