Database Reference
In-Depth Information
"mem" : {
"bits" : 64,
"resident" : 3580,
"virtual" : 9000,
"mapped" : 6591
}
"ok" : 1 }
The
globalLock
section is important because it indicates the total amount of time the
server has spent in a write lock. A high ratio may indicate a write bottleneck. The
currentQueue
is perhaps a more concrete representation of bottlenecks. If a large
number of writes or reads are waiting in the queue, then some kind of optimization
may be in order.
The
mem
section shows how the
mongod
process is using memory. The
bits
field
indicates that this is a 64-bit machine.
resident
is the amount of physical memory
occupied by MongoDB.
virtual
is the number of megabytes the process has mapped
to virtual memory, and
mapped
, a subset of
virtual
, indicates how much of that mem-
ory is mapped for the data files alone. In this case, about 6.5 GB of data files are
mapped to virtual memory, with 3.5
GB
of that in physical memory. I've repeatedly
stated that the working set should ideally fit in
RAM
. The
mem
section can provide an
approximate indication of whether this is the case.
The
serverStatus
output changes and improves with each MongoDB release, and
thus documenting it in a semi-permanent medium like this topic isn't always helpful.
You can see a detailed and up-to-date interpretation of this output at
http://
www.mongodb.org/display/DOCS/serverStatus
.
top
The
top
command displays operation counters on a per-database level. If your appli-
cation uses multiple physical databases, or if you'd like to see how long on average
operations are taking, then this is a useful command. Here's some sample output:
> use admin
> db.runCommand({top: 1}) {
"totals" : { "cloud-docs" :
{ "total" : { "time" : 194470, "count" : 20 },
"readLock" : { "time" : 324, "count" : 12 },
"writeLock" : { "time" : 194146, "count" : 8 },
"queries" : { "time" : 194470, "count" : 20 },
"getmore" : { "time" : 0, "count" : 0 } },
"ok" : 1}
Here you see that a lot of time is being spent in a write lock. It may be worthwhile to
investigate this further to see whether writes are unnecessarily slow.
db.currentOp()
It's frequently useful to know what MongoDB is doing
right now
. The
db.currentOp()
method exposes this information by returning a list of all the operations currently
running along with any other operations waiting to run. Here's an example of the
method's output, run against the shard cluster you set up in the previous chapter: