connPoolStats

Definition

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:

  1. 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 poolsconnection 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 mongosruns on a 4-core machine.

  1. 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.

  1. {
  2. "numClientConnections" : <num>,
  3. "numAScopedConnections" : <num>,
  4. "totalInUse" : <num>,
  5. "totalAvailable" : <num>,
  6. "totalCreated" : <num>,
  7. "totalRefreshing" : <num>,
  8. "pools" : {
  9. "NetworkInterfaceTL-TaskExecutorPool-0" : {
  10. "poolInUse" : <num>,
  11. "poolAvailable" : <num>,
  12. "poolCreated" : <num>,
  13. "poolRefreshing" : <num>,
  14. "cfg1.example.net:27019" : {
  15. "inUse" : <num>,
  16. "available" : <num>,
  17. "created" : <num>,
  18. "refreshing" :<num>
  19. }
  20. },
  21. "NetworkInterfaceTL-TaskExecutorPool-1" : {
  22. "poolInUse" : <num>,
  23. "poolAvailable" : <num>,
  24. "poolCreated" : <num>,
  25. "poolRefreshing" : <num>,
  26. "cfg1.example.net:27019" : {
  27. "inUse" : <num>,
  28. "available" : <num>,
  29. "created" : <num>,
  30. "refreshing" :<num>
  31. }
  32. },
  33. "NetworkInterfaceTL-TaskExecutorPool-2" : {
  34. "poolInUse" : <num>,
  35. "poolAvailable" : <num>,
  36. "poolCreated" : <num>,
  37. "poolRefreshing" : <num>,
  38. "cfg1.example.net:27019" : {
  39. "inUse" : <num>,
  40. "available" : <num>,
  41. "created" : <num>,
  42. "refreshing" :<num>
  43. }
  44. },
  45. "NetworkInterfaceTL-TaskExecutorPool-3" : {
  46. "poolInUse" : <num>,
  47. "poolAvailable" : <num>,
  48. "poolCreated" : <num>,
  49. "poolRefreshing" : <num>,
  50. "cfg1.example.net:27019" : {
  51. "inUse" : <num>,
  52. "available" : <num>,
  53. "created" : <num>,
  54. "refreshing" :<num>
  55. }
  56. },
  57. "NetworkInterfaceTL-ShardRegistry" : {
  58. "poolInUse" : <num>,
  59. "poolAvailable" : <num>,
  60. "poolCreated" : <num>,
  61. "poolRefreshing" : <num>,
  62. "cfg1.example.net:27019" : {
  63. "inUse" : <num>,
  64. "available" : <num>,
  65. "created" : <num>,
  66. "refreshing" :<num>
  67. },
  68. "cfg2.example.net:27019" : {
  69. "inUse" : <num>,
  70. "available" : <num>,
  71. "created" : <num>,
  72. "refreshing" :<num>
  73. },
  74. "cfg3.example.net:27019" : {
  75. "inUse" : <num>,
  76. "available" : <num>,
  77. "created" : <num>,
  78. "refreshing" :<num>
  79. },
  80. "shard1.example.net:27018" : {
  81. "inUse" : <num>,
  82. "available" : <num>,
  83. "created" : <num>,
  84. "refreshing" :<num>
  85. },
  86. "shard2.example.net:27018" : {
  87. "inUse" : <num>,
  88. "available" : <num>,
  89. "created" : <num>,
  90. "refreshing" :<num>
  91. }
  92. },
  93. "global" : {
  94. "poolInUse" : <num>,
  95. "poolAvailable" : <num>,
  96. "poolCreated" : <num>,
  97. "poolRefreshing" : <num>,
  98. "cfg3.example.net:27019" : {
  99. "inUse" : <num>,
  100. "available" : <num>,
  101. "created" : <num>,
  102. "refreshing" :<num>
  103. },
  104. "cfg1.example.net:27019" : {
  105. "inUse" : <num>,
  106. "available" : <num>,
  107. "created" : <num>,
  108. "refreshing" :<num>
  109. },
  110. "cfg2.example.net:27019" : {
  111. "inUse" : <num>,
  112. "available" : <num>,
  113. "created" : <num>,
  114. "refreshing" :<num>
  115. },
  116. "shard2.example.net:27018" : {
  117. "inUse" : <num>,
  118. "available" : <num>,
  119. "created" : <num>,
  120. "refreshing" :<num>
  121. },
  122. "shard1.example.net:27018" : {
  123. "inUse" : <num>,
  124. "available" : <num>,
  125. "created" : <num>,
  126. "refreshing" :<num>
  127. }
  128. }
  129. },
  130. "hosts" : {
  131. "cfg3.example.net:27019" : {
  132. "inUse" : <num>,
  133. "available" : <num>,
  134. "created" : <num>,
  135. "refreshing" :<num>
  136. },
  137. "cfg1.example.net:27019" : {
  138. "inUse" : <num>,
  139. "available" : <num>,
  140. "created" : <num>,
  141. "refreshing" :<num>
  142. },
  143. "cfg2.example.net:27019" : {
  144. "inUse" : <num>,
  145. "available" : <num>,
  146. "created" : <num>,
  147. "refreshing" :<num>
  148. },
  149. "shard2.example.net:27018" : {
  150. "inUse" : <num>,
  151. "available" : <num>,
  152. "created" : <num>,
  153. "refreshing" :<num>
  154. },
  155. "shard1.example.net:27018" : {
  156. "inUse" : <num>,
  157. "available" : <num>,
  158. "created" : <num>,
  159. "refreshing" :<num>
  160. }
  161. },
  162. "replicaSets" : {
  163. "csRS" : {
  164. "hosts" : [
  165. {
  166. "addr" : "cfg1.example.net:27019",
  167. "ok" : <bool>,
  168. "ismaster" : <bool>,
  169. "hidden" : <bool>,
  170. "secondary" : <bool>,
  171. "pingTimeMillis" : <num>
  172. },
  173. {
  174. "addr" : "cfg2.example.net:27019",
  175. "ok" : <bool>,
  176. "ismaster" : <bool>,
  177. "hidden" : <bool>,
  178. "secondary" : <bool>,
  179. "pingTimeMillis" : <num>
  180. },
  181. {
  182. "addr" : "cfg3.example.net:27019",
  183. "ok" : <bool>,
  184. "ismaster" : <bool>,
  185. "hidden" : <bool>,
  186. "secondary" : <bool>,
  187. "pingTimeMillis" : <num>
  188. }
  189. ]
  190. },
  191. "shardB" : {
  192. "hosts" : [
  193. {
  194. "addr" : "shard2.example.net:27018",
  195. "ok" : <bool>,
  196. "ismaster" : <bool>,
  197. "hidden" : <bool>,
  198. "secondary" : <bool>,
  199. "pingTimeMillis" : <num>
  200. }
  201. ]
  202. },
  203. "shardA" : {
  204. "hosts" : [
  205. {
  206. "addr" : "shard1.example.net:27018",
  207. "ok" : <bool>,
  208. "ismaster" : <bool>,
  209. "hidden" : <bool>,
  210. "secondary" : <bool>,
  211. "pingTimeMillis" : <num>
  212. }
  213. ]
  214. }
  215. },
  216. "ok" : 1,
  217. "$clusterTime" : {
  218. "clusterTime" : <timestamp>,
  219. "signature" : <document>
  220. },
  221. "operationTime" : <timestamp>
  222.  
  223. }

Output

  • connPoolStats.totalInUse
  • Reports the total number of outgoing connections from the currentmongod/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 currentmongod/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. Amongod or mongos 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:
  1. {
  2. "poolInUse" : <num>,
  3. "poolAvailable" : <num>,
  4. "poolCreated" : <num>,
  5. "poolRefreshing" : <num>,
  6. "[host1]" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" : <num> },
  7. "[host2]" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" : <num> },
  8. ...
  9. }

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-0NetworkInterfaceTL-TaskExecutorPool-7for an 8-core processor.

See also

taskExecutorPoolSize

  • 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.pools.global
  • Displays the DBClient-based pool statistics.
  • 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].

  • connPoolStats.hosts.[host].created

  • Reports the number of connections to the [host] ever created.

  • connPoolStats.hosts.[host].inUse

  • 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 currentmongod/mongos.

    • connPoolStats.replicaSets.replicaSet
    • Reports on each replica set connected to thecurrent mongod/mongos.

    • connPoolStats.replicaSets.[replicaSets].hosts

    • Holds an array of documents that reports on eachmember in the replica set.

These values derive from the replica set status values.

  1. - <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>addr</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].addr)
  2. -

Reports the address for the member in the replica setin [hostname]:[port] format.

  1. - <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>ok</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].ok)
  2. -

Reports false when:

  1. - the current [<code>mongos</code>]($4091b4343bffff04.md#bin.mongos) or [<code>mongod</code>]($1cde9863b9db90a4.md#bin.mongod) cannot connectto instance.
  2. - 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.

  1. - <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>ismaster</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].ismaster)
  2. -

Reports true if thishost is theprimary member of the replica set.

  1. - <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>hidden</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].hidden)
  2. -

Reports true if thishost is ahidden member of the replica set.

  1. - <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>secondary</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].secondary)
  2. -

Reports true if thishost is asecondary member of the replica set.

  1. - <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>pingTimeMillis</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].pingTimeMillis)
  2. -

Reports the ping time in milliseconds from the mongos ormongod to thishost.

  1. - <code>connPoolStats.replicaSets.[replicaSet].hosts[n].</code><code>tags</code>[]($c37284dd9ed98d83.md#connPoolStats.replicaSets.[replicaSet].hosts[n].tags)
  2. -

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.