This ticket adds a new flag to mongos to allow users to control the rate at which new connections from a mongos to a mongod are created.
This functionality is aimed at mitigating connection storms in the following scenario:
- a mongos has a high number of connections established to a given shard
- the shard's primary becomes temporarily unavailable (e.g.: during an election or a temporary network glitch)
- the shard's primary becomes available again (e.g.: new primary elected, network glitch resolved)
- the mongos will try to re-establish or refresh all connection to the shard's primary
It is possible for mongos nodes to overwhelm the primary with connection requests, which may have adverse consequences.
The ShardingTaskExecutorPoolMaxConnecting flag allows users to limit the rate at which mongos nodes add connectons to connection pools. The flag changes mongos behavior so that only N connections can be in the processing state at any one time (in setup/refresh) to avoid overwhelming mongod nodes with connection requests.
It is worth noting that this flag is per connection pool, so if a mongos node has C connection pools and ShardingTaskExecutorPoolMaxConnecting is set to N, the node may establish up to C * N connections to a mongod in a scenario like the one described above. Please see
SERVER-25027 for more information on configuring connection pools.
The default value is unlimited for backwards-compatibility purposes. This default value may change in future versions of MongoDB.
This flag is available in MongoDB 3.5.9, 3.4.6, 3.2.15 and newer versions.