Skip to content

Commit 7d062ba

Browse files
committed
VK feedback
1 parent c3d9175 commit 7d062ba

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

source/connect/connection-options/server-selection.txt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,41 @@ customize this algorithm to choose the server that works best for your applicati
2929
Customizing the server selection algorithm might have unintended consequences,
3030
such as degraded read or write performance.
3131

32-
Default Algorithm
33-
-----------------
32+
Server Selection Algorithm
33+
--------------------------
3434

3535
When the {+driver-short+} executes a read operation, it performs the following steps,
3636
in order, to select a MongoDB deployment:
3737

38-
1. Selects all servers that match the active read preference from the list of known servers.
38+
1. Selects all servers from the list of known servers suitable for the requested
39+
operation, barring those that the driver considers unavailable or problematic
40+
41+
1. For reads, selects all servers that match the active read preference
42+
43+
#. For writes, selects all writeable servers
3944

40-
#. If at least one readable server exists, calls the user-defined
41-
server-selector function and passes in the list from the previous step
45+
#. Calls the user-defined server-selector function, if the user provides one, and passes in
46+
the list from the previous step
4247

4348
#. Applies the ``localThreshold`` connection setting to the list of
4449
servers returned from the function
4550

46-
#. Selects a server at random from the servers still on the list and
47-
executes the operation against this server
51+
#. Selects at most two random servers from the list of servers that match the
52+
preceding criteria, then selects the server with fewer outstanding concurrent operations
4853

4954
When the {+driver-short+} executes a write operation, it begins by selecting all writeable
5055
servers from the list of known servers, not just those that match the active read preference.
5156
The remaining steps are identical to the preceding list.
5257

53-
To learn more about the default server selection algorithm, which the driver follows
54-
when you don't specify any custom server selection logic, see
58+
To learn more about the MongoDB server selection algorithm, see
5559
:manual:`Server Selection Algorithm </core/read-preference-mechanics/>` in the
5660
{+mdb-server+} manual.
5761

5862
Implement Custom Server Selection Logic
5963
---------------------------------------
6064

6165
You can implement your own custom server selection logic by creating a class that
62-
implements the ``ServerSelector`` interface and overrides the ``select()`` method. The following
66+
implements the ``ServerSelector`` interface. The following
6367
example shows a simple custom server selection class that selects servers with a ``type``
6468
value of ``ServerType.REPLICA_SET_SECONDARY``:
6569

0 commit comments

Comments
 (0)