Skip to content

DOCSP-7543 support prewarming mongos routing table and connection pool #3983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 109 additions & 2 deletions source/reference/parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2379,7 +2379,7 @@ Sharding Parameters

Default: 1

|mongos-only|
|both|

Minimum number of outbound connections each TaskExecutor connection
pool can open to any given :binary:`~bin.mongod` instance.
Expand All @@ -2390,6 +2390,19 @@ Sharding Parameters
connections until :parameter:`ShardingTaskExecutorPoolHostTimeoutMS`
milliseconds pass without any application using that pool.

For a :binary:`~bin.mongos` using the
:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
parameter, the ``ShardingTaskExecutorPoolMinSize`` parameter also
controls how many connections to each shard host are established on
startup of the :binary:`~bin.mongos` instance before it begins
accepting incoming client connections.

.. note::

In MongoDB 4.4, the
:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
parameter is enabled by default for the :binary:`~bin.mongos`.

You can only set this parameter during start-up and cannot change
this setting using the :dbcommand:`setParameter` database command.

Expand All @@ -2401,7 +2414,8 @@ Sharding Parameters
pools, where ``n`` is the number of cores. See
:parameter:`taskExecutorPoolSize`.

.. seealso:: :parameter:`ShardingTaskExecutorPoolMaxSize`
.. seealso:: - :parameter:`ShardingTaskExecutorPoolMaxSize`
- :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`

.. parameter:: ShardingTaskExecutorPoolRefreshRequirementMS

Expand Down Expand Up @@ -2574,6 +2588,99 @@ Sharding Parameters

- :parameter:`ShardingTaskExecutorPoolMinSize`

.. parameter:: loadRoutingTableOnStartup

.. versionadded:: 4.4

Type: boolean

*Default*: true

|mongos-only|

Configures a :binary:`~bin.mongos` instance to preload the routing
table for a sharded cluster on startup. With this setting
enabled, the :binary:`~bin.mongos` caches the cluster-wide routing
table for each sharded collection as part of its startup procedure,
before it begins accepting client connections.

Without this setting enabled, the :binary:`~bin.mongos` only loads
a routing table as needed for incoming client connections, and only
loads the specific routing table for the namespace of a given
request.

A :binary:`~bin.mongos` instance with the
:parameter:`loadRoutingTableOnStartup` parameter enabled may
experience longer startup times, but will result in faster servicing
of initial client connections once started.

:parameter:`loadRoutingTableOnStartup` is enabled by default.

You can only set this parameter on startup, using either the
:setting:`setParameter` configuration file setting or the
:option:`--setParameter <mongos --setParameter>` command line option.

.. parameter:: warmMinConnectionsInShardingTaskExecutorPoolOnStartup

.. versionadded:: 4.4

Type: boolean

*Default*: true

|mongos-only|

Configures a :binary:`~bin.mongos` instance to prewarm its connection
pool on startup. With this parameter enabled, the
:binary:`~bin.mongos` attempts to establish
:parameter:`ShardingTaskExecutorPoolMinSize` network
connections to each shard server as part of its startup procedure,
before it begins accepting client connections.

A timeout for this behavior can be configured with the
:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS`
parameter. If this timeout is reached, the :binary:`~bin.mongos` will
begin accepting client connections regardless of the size of its
connection pool.

A :binary:`~bin.mongos` instance with this parameter enabled may
experience longer startup times, but will result in faster servicing
of initial client connections once started.

:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup` is
enabled by default.

You can only set this parameter on startup, using either the
:setting:`setParameter` configuration file setting or the
:option:`--setParameter <mongos --setParameter>` command line option.

.. seealso:: - :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS`
- :parameter:`ShardingTaskExecutorPoolMinSize`

.. parameter:: warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS

.. versionadded:: 4.4

Type: integer

*Default*: 2000 (i.e. 2 seconds)

|mongos-only|

Sets the timeout threshold in milliseconds for a
:binary:`~bin.mongos` to wait for :parameter:`ShardingTaskExecutorPoolMinSize`
connections to be established per shard host when using the
:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
parameter. If this timeout is reached, the :binary:`~bin.mongos` will
begin accepting client connections regardless of the size of its
connection pool.

You can only set this parameter on startup, using either the
:setting:`setParameter` configuration file setting or the
:option:`--setParameter <mongos --setParameter>` command line option.

.. seealso:: - :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
- :parameter:`ShardingTaskExecutorPoolMinSize`

.. parameter:: migrateCloneInsertionBatchDelayMS

Expand Down
45 changes: 45 additions & 0 deletions source/release-notes/4.4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,51 @@ need to be moved) as of the time the command is run or need to be
moved. With the command, users can verify that initial chunk creation
and migration has finished.

Improved ``mongos`` Startup Procedure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Starting with MongoDB 4.4, :binary:`~bin.mongos` adds the following new
default startup behavior:

- :binary:`~bin.mongos` will now preload a sharded cluster's routing
table on startup, rather than doing so on-demand for the first
incoming client connection.

- :binary:`~bin.mongos` will now prewarm its connection pool to shard
hosts on startup, rather than doing so on-demand for incoming
client connections.

This behavior results in faster servicing of initial client
connections after a :binary:`~bin.mongos` instance is started or
restarted. In particular, this allows sites that employ multiple
:binary:`~bin.mongos` instances to restart them as necessary, or add new
ones, without initial client requests to those instances needing to wait
on connection establishment.

Both routing table preloading and connection pool prewarming are enabled
by default.

MongoDB 4.4 adds the following parameters for controlling this behavior:

- :parameter:`loadRoutingTableOnStartup`

- *Default*: ``true`` (Enabled)
- Enables or disables support for preloading the routing table on
startup for the :binary:`~bin.mongos`.

- :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`

- *Default*: ``true`` (Enabled)
- Enables or disables support for prewarming the connection pool on
startup for the :binary:`~bin.mongos`.

- :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS`

- *Default*: ``2000`` (2 seconds)
- Sets the timeout in milliseconds before client connections
to the :binary:`~bin.mongos` are allowed regardless of established
connection pool size.

Platform Support
----------------

Expand Down