-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Labels:None
Description
A new field 'shardingStatistics.numHostsTargeted' was added to the output of the serverStatus command in order to indicate the number of shards targeted for CRUD ops and the aggregation command. Each time either a CRUD op or agg command is run, these metrics are incremented. The new field looks like:
"numHostsTargeted" : { "find" : { "allShards" : NumberLong(<num>), "manyShards" : NumberLong(<num>), "oneShard" : NumberLong(<num>), "unsharded" : NumberLong(<num>) }, "insert" : { "allShards" : NumberLong(<num>), "manyShards" : NumberLong(<num>), "oneShard" : NumberLong(<num>), "unsharded" : NumberLong(<num>) }, "update" : { "allShards" : NumberLong(<num>), "manyShards" : NumberLong(<num>), "oneShard" : NumberLong(<num>), "unsharded" : NumberLong(<num>) }, "delete" : { "allShards" : NumberLong(<num>), "manyShards" : NumberLong(<num>), "oneShard" : NumberLong(<num>), "unsharded" : NumberLong(<num>) }, "aggregate" : { "allShards" : NumberLong(<num>), "manyShards" : NumberLong(<num>), "oneShard" : NumberLong(<num>), "unsharded" : NumberLong(<num>) }, }
allShards - all shards were targeted for a command
manyShards - more than one shard was targeted for a command
oneShard - only one shard was targeted for a command
unsharded - the collection the command was run on is unsharded
Description of Linked Ticket
Currently the mongos collects the opcounter metrics etc, with which we can get an idea on the incoming operations to the mongos. The mongos dispatch the operations to the shards:
- If the operation only targets one shard, then the mongos only needs to dispatch it to one shard.
- However, if the operation is a scatter-gather operation or targets a sub set of shards, then the mongos would need to dispatch the operation to multiple shards. In this case, the mongos is doing more work for such operation than the targeted operation, and there would be more load on the mongos.
Currently we have added a metric to indicate the amount of sharded updates done with only _id in query (SERVER-41184). It would be nice to expose the number of shards targeted for the operations (find, aggregate, etc), so that we can have some insight on the number of outgoing operations from the mongos, to understand the (outgoing) workload on the mongos.
Scope of changes
Impact to Other Docs
MVP (Work and Date)
Resources (Scope or Design Docs, Invision, etc.)
- backported by
-
DOCS-14456 [BACKPORT] [v4.0] Add metrics on the mongos to indicate the number of shards targeted for the commands (find, aggregate, etc)
- Closed
-
DOCS-14558 [BACKPORT] [v4.2] Add metrics on the mongos to indicate the number of shards targeted for the commands (find, aggregate, etc)
- Closed
- documents
-
SERVER-43617 Add metrics on the mongos to indicate the number of shards targeted for the commands (find, aggregate, etc)
- Closed