Database Reference
In-Depth Information
are likely to make small changes to the index and data file formats, and this will
require a slightly more lengthy upgrade process. Always check the latest release notes
for accurate recommendations.
Of course, when upgrading MongoDB, you're probably going to be upgrading a
replicated cluster. In the case of a replica set, the general strategy is to upgrade one
node at a time, starting with the secondary nodes.
10.4
Performance troubleshooting
In this final section, I outline a heuristic for diagnosing and resolving performance
issues.
Most of the performance issues in MongoDB deployments can be traced to a sin-
gle source: the hard disk. In essence, the more pressure placed on the disk, the
slower MongoDB runs. Thus the goal of most performance optimizations is to reduce
reliance on disk. There are several ways to accomplish this, but before we look at
them, it's useful to know how to ascertain disk performance in the first place. On
Unix derivatives, the iostat tool is ideal for this. In the following example, I use the
-x option to show extended statistics, and you specify 2 to display those stats at two-
second intervals: 10
$ iostat -x 2
Device: rsec/s
wsec/s avgrq-sz avgqu-sz
await svctm %util
sdb
0.00
3101.12
10.09
32.83 101.39
1.34 29.36
Device: rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sdb 0.00 2933.93 9.87 23.72 125.23 1.47 34.13
For a detailed description of each of these fields, consult your system's man pages. For
a quick diagnostic, you'll be most interested in the last three columns. await indicates
the average time in milliseconds for serving I / O requests. This average includes time
spent in the I / O queue and time spent actually servicing I / O requests. svctime indi-
cates the average time spent serving requests alone. And %util is the percentage of
CPU time spent issuing I / O requests to the disk.
The preceding iostat snippet shows moderate disk usage. The average time wait-
ing on I / O is around 100 ms (hint: that's a lot!), the average service time is about 1 ms,
and the percent utilization is about 30%. If you were to investigate the MongoDB logs
on this machine, you'd likely see numerous slow operations (queries, inserts, or other-
wise). In fact, it's those slow operations that would initially alerts you to a potential
problem. The iostat output can help you confirm the problem. Note that it's not
uncommon to find MongoDB users whose systems approach 100% disk utilization;
these users generally find themselves frustrated with MongoDB, though the heavy uti-
lization is rarely MongoDB's fault alone. In the next five sections, I'll present some
remedies that optimize database operations and ease the load off the disk.
10
Note that this example is Linux-specific. On Mac OS X, the command is iostat -w 2 .
Search WWH ::




Custom Search