Skip to content

Commit 776be7b

Browse files
committed
DOCSP-7543 support prewarming mongos routing table and connection pool
1 parent e42a5b8 commit 776be7b

File tree

2 files changed

+154
-2
lines changed

2 files changed

+154
-2
lines changed

source/reference/parameters.txt

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,7 @@ Sharding Parameters
23792379

23802380
Default: 1
23812381

2382-
|mongos-only|
2382+
|both|
23832383

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

2393+
For a :binary:`~bin.mongos` using the
2394+
:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
2395+
parameter, the ``ShardingTaskExecutorPoolMinSize`` parameter also
2396+
controls how many connections to each shard host are established on
2397+
startup of the :binary:`~bin.mongos` instance before it begins
2398+
accepting incoming client connections.
2399+
2400+
.. note::
2401+
2402+
In MongoDB 4.4, the
2403+
:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
2404+
parameter is enabled by default for the :binary:`~bin.mongos`.
2405+
23932406
You can only set this parameter during start-up and cannot change
23942407
this setting using the :dbcommand:`setParameter` database command.
23952408

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

2404-
.. seealso:: :parameter:`ShardingTaskExecutorPoolMaxSize`
2417+
.. seealso:: - :parameter:`ShardingTaskExecutorPoolMaxSize`
2418+
- :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
24052419

24062420
.. parameter:: ShardingTaskExecutorPoolRefreshRequirementMS
24072421

@@ -2574,6 +2588,99 @@ Sharding Parameters
25742588

25752589
- :parameter:`ShardingTaskExecutorPoolMinSize`
25762590

2591+
.. parameter:: loadRoutingTableOnStartup
2592+
2593+
.. versionadded:: 4.4
2594+
2595+
Type: boolean
2596+
2597+
*Default*: true
2598+
2599+
|mongos-only|
2600+
2601+
Configures a :binary:`~bin.mongos` instance to preload the routing
2602+
table for a sharded cluster on startup. With this setting
2603+
enabled, the :binary:`~bin.mongos` caches the cluster-wide routing
2604+
table for each sharded collection as part of its startup procedure,
2605+
before it begins accepting client connections.
2606+
2607+
Without this setting enabled, the :binary:`~bin.mongos` only loads
2608+
a routing table as needed for incoming client connections, and only
2609+
loads the specific routing table for the namespace of a given
2610+
request.
2611+
2612+
A :binary:`~bin.mongos` instance with the
2613+
:parameter:`loadRoutingTableOnStartup` parameter enabled may
2614+
experience longer startup times, but will result in faster servicing
2615+
of initial client connections once started.
2616+
2617+
:parameter:`loadRoutingTableOnStartup` is enabled by default.
2618+
2619+
You can only set this parameter on startup, using either the
2620+
:setting:`setParameter` configuration file setting or the
2621+
:option:`--setParameter <mongos --setParameter>` command line option.
2622+
2623+
.. parameter:: warmMinConnectionsInShardingTaskExecutorPoolOnStartup
2624+
2625+
.. versionadded:: 4.4
2626+
2627+
Type: boolean
2628+
2629+
*Default*: true
2630+
2631+
|mongos-only|
2632+
2633+
Configures a :binary:`~bin.mongos` instance to prewarm its connection
2634+
pool on startup. With this parameter enabled, the
2635+
:binary:`~bin.mongos` attempts to establish
2636+
:parameter:`ShardingTaskExecutorPoolMinSize` network
2637+
connections to each shard server as part of its startup procedure,
2638+
before it begins accepting client connections.
2639+
2640+
A timeout for this behavior can be configured with the
2641+
:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS`
2642+
parameter. If this timeout is reached, the :binary:`~bin.mongos` will
2643+
begin accepting client connections regardless of the size of its
2644+
connection pool.
2645+
2646+
A :binary:`~bin.mongos` instance with this parameter enabled may
2647+
experience longer startup times, but will result in faster servicing
2648+
of initial client connections once started.
2649+
2650+
:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup` is
2651+
enabled by default.
2652+
2653+
You can only set this parameter on startup, using either the
2654+
:setting:`setParameter` configuration file setting or the
2655+
:option:`--setParameter <mongos --setParameter>` command line option.
2656+
2657+
.. seealso:: - :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS`
2658+
- :parameter:`ShardingTaskExecutorPoolMinSize`
2659+
2660+
.. parameter:: warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS
2661+
2662+
.. versionadded:: 4.4
2663+
2664+
Type: integer
2665+
2666+
*Default*: 2000 (i.e. 2 seconds)
2667+
2668+
|mongos-only|
2669+
2670+
Sets the timeout threshold in milliseconds for a
2671+
:binary:`~bin.mongos` to wait for :parameter:`ShardingTaskExecutorPoolMinSize`
2672+
connections to be established per shard host when using the
2673+
:parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
2674+
parameter. If this timeout is reached, the :binary:`~bin.mongos` will
2675+
begin accepting client connections regardless of the size of its
2676+
connection pool.
2677+
2678+
You can only set this parameter on startup, using either the
2679+
:setting:`setParameter` configuration file setting or the
2680+
:option:`--setParameter <mongos --setParameter>` command line option.
2681+
2682+
.. seealso:: - :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
2683+
- :parameter:`ShardingTaskExecutorPoolMinSize`
25772684

25782685
.. parameter:: migrateCloneInsertionBatchDelayMS
25792686

source/release-notes/4.4.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,51 @@ need to be moved) as of the time the command is run or need to be
390390
moved. With the command, users can verify that initial chunk creation
391391
and migration has finished.
392392

393+
Improved ``mongos`` Startup Procedure
394+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
395+
396+
Starting with MongoDB 4.4, :binary:`~bin.mongos` adds the following new
397+
default startup behavior:
398+
399+
- :binary:`~bin.mongos` will now preload a sharded cluster's routing
400+
table on startup, rather than doing so on-demand for the first
401+
incoming client connection.
402+
403+
- :binary:`~bin.mongos` will now prewarm its connection pool to shard
404+
hosts on startup, rather than doing so on-demand for incoming
405+
client connections.
406+
407+
This behavior results in faster servicing of initial client
408+
connections after a :binary:`~bin.mongos` instance is started or
409+
restarted. In particular, this allows sites that employ multiple
410+
:binary:`~bin.mongos` instances to restart them as necessary, or add new
411+
ones, without initial client requests to those instances needing to wait
412+
on connection establishment.
413+
414+
Both routing table preloading and connection pool prewarming are enabled
415+
by default.
416+
417+
MongoDB 4.4 adds the following parameters for controlling this behavior:
418+
419+
- :parameter:`loadRoutingTableOnStartup`
420+
421+
- *Default*: ``true`` (Enabled)
422+
- Enables or disables support for preloading the routing table on
423+
startup for the :binary:`~bin.mongos`.
424+
425+
- :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartup`
426+
427+
- *Default*: ``true`` (Enabled)
428+
- Enables or disables support for prewarming the connection pool on
429+
startup for the :binary:`~bin.mongos`.
430+
431+
- :parameter:`warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS`
432+
433+
- *Default*: ``2000`` (2 seconds)
434+
- Sets the timeout in milliseconds before client connections
435+
to the :binary:`~bin.mongos` are allowed regardless of established
436+
connection pool size.
437+
393438
Platform Support
394439
----------------
395440

0 commit comments

Comments
 (0)