Database Reference
In-Depth Information
application. Using, say, a solid state drive, you may be able to run with much less RAM
(or much greater capacity) than you would otherwise.
Regardless of the type of disk used, serious deployments will generally use, not a
single disk, but a redundant array of disks ( RAID ) instead. Users typically manage a
RAID cluster using Linux's logical volume manager, LVM , with a RAID level of 10.
RAID 10 provides redundancy while maintaining acceptable performance, and is com-
monly used in MongoDB deployments. 2
If your data is spread across multiple databases within the same MongoDB server,
then you can also ensure capacity by using the server's --directoryperdb flag. This
will create a separate directory in the data file path for each database. Using this, you
can conceivably mount a separate volume ( RAID ed or not) for each database. This
may allow you to take advantage of some performance increases, since you'll be able
to read from separate sets of spindles (or solid state drives).
F ILE SYSTEMS
You'll get the best per formance from MongoDB if you run it on the right file system.
Two file systems in particular, ext4 and xfs , feature fast, contiguous disk allocation.
Using these file systems will speed up MongoDB's frequent preallocations.
Once you mount your fast file system, you can achieve another performance gain
by disabling updates to files' last access time ( atime ). Normally, the operating system
will update a file's atime every time the file is read or written. In a database environ-
ment, this amounts to a lot of unnecessary work. Disabling atime on Linux is relatively
easy. First, make a backup of the file system config file. Then open the original file in
your favorite editor:
sudo mv /etc/fstab /etc/fstab.bak
sudo vim /etc/fstab
For each mounted volume, you'll see a list of settings aligned by column. Under the
options column, add the noatime directive:
# file-system mount type options dump pass
UUID=8309beda-bf62-43 /ssd ext4 noatime 0 2
Then save your work. The new settings should take effect immediately.
F ILE DESCRIPTORS
Some Linux systems cap the number of allowable open file descriptors at 1,024. This
is occasionally too low for MongoDB and may result in errors opening connections
(which you'll see clearly in the logs). Naturally, MongoDB requires a file descriptor
for each open file and network connection. Assuming you store your data files in a
folder with the word data in it, you can see the number of data file descriptors using
lsof and a few well-placed pipes:
lsof | grep mongo | grep data | wc -l
2
For an overview of RAID levels, see http://en.wikipedia.org/wiki/Standard_RAID_levels .
Search WWH ::




Custom Search