connPoolStats
On this page
Definition
connPoolStats
The command
connPoolStats
returns information regarding the open outgoing connections from the current database instance to other members of the sharded cluster or replica set.To run
connPoolStats
, use thedb.runCommand( { <command> } )
method.Note
connPoolStats
only returns meaningful results formongos
instances and formongod
instances in sharded clusters.The command takes the following form:
db.runCommand( { "connPoolStats" : 1 } ) The value of the argument (i.e.
1
) does not affect the output of the command.
Behavior
connPoolStats
includes aggregated statistics in its
output:
The
hosts
field displays the information aggregated by host.The
pools
field displays the information aggregated by pool.
Note
To avoid interference with any running operations,
connPoolStats
does not take any locks. As such, the
counts may change slightly as connPoolStats
gathers
information, resulting in slight differences between the
hosts
and pools
connection counts.
Example
The following operation uses the db.runCommand()
method to
run the connPoolStats
command on a mongos
of a
sharded cluster. The sharded cluster has 2 shards, each a single-member
replica set, and a config server replica set. The mongos
runs on a 4-core machine.
db.runCommand( { "connPoolStats" : 1 } )
The command returns the output of the following form:
Note
The connPoolStats
output varies depending on the
deployment and the member against which you run
connPoolStats
among other factors.
{ "numClientConnections" : <num>, "numAScopedConnections" : <num>, "totalInUse" : <num>, "totalAvailable" : <num>, "totalCreated" : <num>, "totalRefreshing" : <num>, "replicaSetMatchingStrategy" : <string>, "pools" : { "NetworkInterfaceTL-TaskExecutorPool-0" : { "poolInUse" : <num>, "poolAvailable" : <num>, "poolCreated" : <num>, "poolRefreshing" : <num>, "cfg1.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> } }, "NetworkInterfaceTL-TaskExecutorPool-1" : { "poolInUse" : <num>, "poolAvailable" : <num>, "poolCreated" : <num>, "poolRefreshing" : <num>, "cfg1.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> } }, "NetworkInterfaceTL-TaskExecutorPool-2" : { "poolInUse" : <num>, "poolAvailable" : <num>, "poolCreated" : <num>, "poolRefreshing" : <num>, "cfg1.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> } }, "NetworkInterfaceTL-TaskExecutorPool-3" : { "poolInUse" : <num>, "poolAvailable" : <num>, "poolCreated" : <num>, "poolRefreshing" : <num>, "cfg1.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> } }, "NetworkInterfaceTL-ShardRegistry" : { "poolInUse" : <num>, "poolAvailable" : <num>, "poolCreated" : <num>, "poolRefreshing" : <num>, "cfg1.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "cfg2.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "cfg3.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "shard1.example.net:27018" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "shard2.example.net:27018" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> } }, "global" : { "poolInUse" : <num>, "poolAvailable" : <num>, "poolCreated" : <num>, "poolRefreshing" : <num>, "cfg3.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "cfg1.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "cfg2.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "shard2.example.net:27018" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "shard1.example.net:27018" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> } } }, "hosts" : { "cfg3.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "cfg1.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "cfg2.example.net:27019" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "shard2.example.net:27018" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> }, "shard1.example.net:27018" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" :<num> } }, "replicaSets" : { "csRS" : { "hosts" : [ { "addr" : "cfg1.example.net:27019", "ok" : <bool>, "ismaster" : <bool>, "hidden" : <bool>, "secondary" : <bool>, "pingTimeMillis" : <num> }, { "addr" : "cfg2.example.net:27019", "ok" : <bool>, "ismaster" : <bool>, "hidden" : <bool>, "secondary" : <bool>, "pingTimeMillis" : <num> }, { "addr" : "cfg3.example.net:27019", "ok" : <bool>, "ismaster" : <bool>, "hidden" : <bool>, "secondary" : <bool>, "pingTimeMillis" : <num> } ] }, "shardB" : { "hosts" : [ { "addr" : "shard2.example.net:27018", "ok" : <bool>, "ismaster" : <bool>, "hidden" : <bool>, "secondary" : <bool>, "pingTimeMillis" : <num> } ] }, "shardA" : { "hosts" : [ { "addr" : "shard1.example.net:27018", "ok" : <bool>, "ismaster" : <bool>, "hidden" : <bool>, "secondary" : <bool>, "pingTimeMillis" : <num> } ] } }, "ok" : 1, "$clusterTime" : { "clusterTime" : <timestamp>, "signature" : <document> }, "operationTime" : <timestamp> }
Output
connPoolStats.totalAvailable
Reports the total number of available outgoing connections from the current
mongod
/mongos
instance to other members of the sharded cluster or replica set.
connPoolStats.totalCreated
Reports the total number of outgoing connections ever created by the current
mongod
/mongos
instance to other members of the sharded cluster or replica set.
connPoolStats.totalInUse
Reports the total number of outgoing connections from the current
mongod
/mongos
instance to other members of the sharded cluster or replica set that are currently in use.
connPoolStats.totalRefreshing
Reports the total number of outgoing connections from the current
mongod
/mongos
instance to other members of the sharded cluster or replica set that are currently being refreshed.
connPoolStats.replicaSetMatchingStrategy
On a
mongos
instance, this value reports the policy used by the instance to determine the minimum size limit of its connection pools to nodes within replica sets.On a
mongod
instance, this value reports the policy used by the instance to determine the minimum size limit of its connection pools to nodes within other replica sets.The policy for
mongos
andmongod
can be set with theShardingTaskExecutorPoolReplicaSetMatching
parameter.Note
If the
ShardingTaskExecutorPoolReplicaSetMatching
is set to"automatic"
, thereplicaSetMatchingStrategy
still describes the actual policy being used, not"automatic"
. To find the value of theShardingTaskExecutorPoolReplicaSetMatching
, usegetParameter
which returns the value of the server parameter:db.adminCommand( { getParameter : 1, "ShardingTaskExecutorPoolReplicaSetMatching" : 1 } )
connPoolStats.numClientConnection
Reports the number of active and stored outgoing synchronous connections from the current
mongod
/mongos
instance to other members of the sharded cluster or replica set.These connections are a part of a pool that is a subset of the data reported by
totalAvailable
,totalCreated
, andtotalInUse
.
connPoolStats.numAScopedConnection
Reports the number of active and stored outgoing scoped synchronous connections from the current
mongod
/mongos
instance to other members of the sharded cluster or replica set.These connections are a part of a pool that is a subset of the data reported by
totalAvailable
,totalCreated
, andtotalInUse
.
connPoolStats.pools
Reports on connection statistics (in use/available/created/refreshing) grouped by the connection pools. A
mongod
ormongos
has two distinct families of outgoing connection pools:DBClient-based pools (the "write path") and
NetworkInterfaceTL-based pools (the "read path").
For each pool, the command returns a document that resembles the following:
{ "poolInUse" : <num>, "poolAvailable" : <num>, "poolCreated" : <num>, "poolRefreshing" : <num>, "[host1]" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" : <num> }, "[host2]" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" : <num> }, ... } Note
If there are no connections (in use/available/created/refreshing) for a particular pool, the
connPoolStats
does not return statistics for that pool.connPoolStats.pools.NetworkInterfaceTL-TaskExecutorPool-[n]
Displays connection statics related to TaskExecutor pools. Typically, there will be one TaskExecutorPool per core, e.g.
pools.NetworkInterfaceTL-TaskExecutorPool-0
...pools.NetworkInterfaceTL-TaskExecutorPool-7
for an 8-core processor.
connPoolStats.pools.NetworkInterfaceTL-ShardRegistry
Available if the command is run on a member of a sharded cluster.
Displays the pool statistics for the connections between the current
mongod
/mongos
instance and other members of the sharded cluster.
connPoolStats.pools.NetworkInterfaceTL-Replication
Available if the command is run on a member of a replica set.
Displays the pool statistics for the connections between the current
mongod
instance and the other members of the replica set.
connPoolStats.hosts
Reports on connection statistics (in use/available/created/refreshing) grouped by the hosts.
Contains documents that represent a report of connections between the current
mongod
/mongos
instance and each member of the sharded cluster or replica set.
connPoolStats.replicaSets
Contains documents that represent a report of information related to each replica set connected to the current
mongod
/mongos
.connPoolStats.replicaSets.replicaSet
Reports on each replica set connected to the current
mongod
/mongos
.
connPoolStats.replicaSets.[replicaSets].hosts
Holds an array of documents that reports on each member in the replica set.
These values derive from the replica set status values.
connPoolStats.replicaSets.[replicaSet].hosts[n].addr
Reports the address for the member in the replica set in
[hostname]:[port]
format.
connPoolStats.replicaSets.[replicaSet].hosts[n].ok
Reports
false
when:This field is for internal use.
connPoolStats.replicaSets.[replicaSet].hosts[n].ismaster
Reports
true
if thishost
is the primary member of the replica set.
connPoolStats.replicaSets.[replicaSet].hosts[n].hidden
Reports
true
if thishost
is a hidden member of the replica set.
connPoolStats.replicaSets.[replicaSet].hosts[n].secondary
Reports
true
if thishost
is a secondary member of the replica set.
connPoolStats.replicaSets.[replicaSet].hosts[n].pingTimeMillis
Reports the ping time in milliseconds from the
mongos
ormongod
to thishost
.
connPoolStats.replicaSets.[replicaSet].hosts[n].tags
Reports the
members[n].tags
, if this member of the set has tags configured.
See also Response for details on the ok
status
field, the operationTime
field and the $clusterTime
field.