connPoolStats
Definition
connPoolStats
- The command
connPoolStats
returns informationregarding the open outgoing connections from the current databaseinstance to other members of the sharded cluster orreplica set.
To run connPoolStats
, use the db.runCommand( { <command> } )
method.
Note
connPoolStats
only returns meaningful results formongos
instances and for mongod
instancesin sharded clusters.
The command takes the following form:
- db.runCommand( { "connPoolStats" : 1 } )
The value of the argument (i.e. 1
) does not affect theoutput of the command.
Behavior
connPoolStats
includes aggregated statistics in itsoutput:
- The
hosts
field displays the informationaggregated by host. - The
pools
field displays the informationaggregated by pool.
Note
To avoid interference with any running operations,connPoolStats
does not take any locks. As such, thecounts may change slightly as connPoolStats
gathersinformation, resulting in slight differences between thehosts
and pools
connection counts.
Example
The following operation uses the db.runCommand()
method torun the connPoolStats
command on a mongos
of asharded cluster. The sharded cluster has 2 shards, each a single-memberreplica 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 thedeployment and the member against which you runconnPoolStats
among other factors.
- {
- "numClientConnections" : <num>,
- "numAScopedConnections" : <num>,
- "totalInUse" : <num>,
- "totalAvailable" : <num>,
- "totalCreated" : <num>,
- "totalRefreshing" : <num>,
- "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 thecurrent
mongod
/mongos
instance to other membersof the sharded cluster or replica set.
connPoolStats.
totalCreated
- Reports the total number of outgoing connections ever created by thecurrent
mongod
/mongos
instance to other membersof 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 thesharded cluster or replica set that are currently in use.
connPoolStats.
totalRefreshing
- Reports the total number of outgoing connections from thecurrent
mongod
/mongos
instance to othermembers of the sharded cluster or replica set thatare currently being refreshed.
connPoolStats.
numClientConnection
- Reports the number of active and stored outgoing synchronousconnections from the current
mongod
/mongos
instanceto other members of the sharded cluster or replica set.
These connections are a part of a pool that is a subset of the datareported by totalAvailable
,totalCreated
, and totalInUse
.
connPoolStats.
numAScopedConnection
- Reports the number of active and stored outgoing scopedsynchronous connections from the current
mongod
/mongos
instance to other members of thesharded cluster or replica set.
These connections are a part of a pool that is a subset of the datareported by totalAvailable
,totalCreated
, and totalInUse
.
connPoolStats.
pools
Reports on connection statistics (inuse/available/created/refreshing) grouped by the connection pools. A
mongod
ormongos
has two distinct families ofoutgoing 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 thefollowing:
- {
- "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 notreturn 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.
NetworkInterfaceTL-TaskExecutorPool-0
…NetworkInterfaceTL-TaskExecutorPool-7
for an 8-core processor.
See also
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 thecurrent mongod
/mongos
instance and othermembers 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 thecurrent mongod
instance and the other members of thereplica set.
connPoolStats.
hosts
- Reports on connection statistics (inuse/available/created/refreshing) grouped by the hosts.
Contains documents that represent a report of connectionsbetween the current mongod
/mongos
instance andeach member of the sharded cluster or replica set.
connPoolStats.hosts.[host].
available
Reports the total number of connections available for connectingto the
[host]
.Reports the number of connections to the
[host]
ever created.- Reports the number of connections to the
[host]
that are currently in use.
connPoolStats.
replicaSets
Contains documents that represent a report ofinformation related to each replica set connected to the current
mongod
/mongos
.connPoolStats.replicaSets.
replicaSet
Reports on each replica set connected to thecurrent
mongod
/mongos
.- Holds an array of documents that reports on eachmember in the replica set.
These values derive from the replica set status values.
- <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>addr</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].addr)
-
Reports the address for the member in the replica setin [hostname]:[port]
format.
- <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>ok</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].ok)
-
Reports false
when:
- the current [<code>mongos</code>]($4091b4343bffff04.md#bin.mongos) or [<code>mongod</code>]($1cde9863b9db90a4.md#bin.mongod) cannot connectto instance.
- the current [<code>mongos</code>]($4091b4343bffff04.md#bin.mongos) or [<code>mongod</code>]($1cde9863b9db90a4.md#bin.mongod) received aconnection exception or error.
This field is for internal use.
- <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>ismaster</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].ismaster)
-
Reports true
if thishost
is theprimary member of the replica set.
- <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>hidden</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].hidden)
-
Reports true
if thishost
is ahidden member of the replica set.
- <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>secondary</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].secondary)
-
Reports true
if thishost
is asecondary member of the replica set.
- <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>pingTimeMillis</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].pingTimeMillis)
-
Reports the ping time in milliseconds from the mongos
ormongod
to thishost
.
- <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>tags</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].tags)
-
Reports the members[n].tags
, if this member of the set hastags configured.
See also Response for details on the ok
statusfield, the operationTime
field and the $clusterTime
field.