Welcome to our multi-part series on operations best practices. This post -- the second of three -- focuses on how to best run MongoDB in your datacenter. Download the <a href="http://www.mongodb.com/lp/white-paper/ops-best-practices"target"_blank">MongoDB Operations Best Practices guide for more detail.
- Laying the Groundwork for MongoDB High Performance
- Managing MongoDB
- Deploying MongoDB with Confidence
Manage MongoDB with Ops Manager
We recommend you install Ops Manager in your data center if you manage large scale MongoDB deployments. Ops Manager can alleviate the overhead of operating MongoDB deployments by as much as 95%. If you prefer a cloud-hosted service, you can use MongoDB Management Service (MMS), which offers many of the benefits of Ops Manager.
With Ops Manager, tasks that were once manual and time-consuming are now automated and possible with just a click of a button or an API call without taking the database offline.
Rely on Ops Manager to:
- Deploy and upgrade your system. Reliably perform the tasks that you have performed manually in the past - from deploying a new cluster, performing upgrades, creating point-in-time backups and more.
- Scale your MongoDB application. Dynamically resize capacity by adding shards and replica set members with Ops Manager.
- Deliver point-in-time recovery and scheduled backups. Restore to any point in time and configure Ops Manager to continuously maintain backups.
- Monitor and get performance alerts. Track over 100 key database and systems health metrics including operations counters, memory and CPU utilization, replication status, open connections, queues and any node status. Metrics are securely reported to Ops Manager and MMS where they are processed, aggregated, alerted and visualized in a browser so administrators can monitor MongoDB in real-time.
Set up custom alerts for key metrics that are out of range. Alerts can be set up for a range of parameters affecting individual hosts, replica sets, agents and backup.
Administrators can use the Ops Manager or MMS interface directly or invoke the Ops Manager RESTful API to integrate with existing enterprise tools.
For more information on the benefits of Ops Manager, download our <a href="http://info.mongodb.com/rs/mongodb/images/OpsManager_DS_rgb.pdf"target"_blank">datasheet. Ops Manager comes with MongoDB Enterprise Advanced but you can <a href="http://www.mongodb.com/subscription/downloads/ops-manager-notice"target"_blank">download an evaluation version. Note, however, that installing Ops Manager is a complex process so we strongly suggest you <a href="http://www.mongodb.com/lp/contact/ops-manager"target"_blank">contact us to get help from one of our expert consultants.
Hardware considerations for smooth-running ops
Of course everyone brings different requirements and use cases to their MongoDB deployment. The specific configuration of your hardware depends on your data, queries, your performance SLA, your availability requirements, and the capabilities of the underlying hardware components. There are, however, a few high-level hardware considerations we would recommend:
- Memory. The working set should fit the RAM. As a general rule, the more RAM the better. MongoDB delegates the management of RAM to the operating system and will use as much RAM as possible until it exhausts what is available. The WiredTiger storage engine offers more memory control by letting you configure how much RAM to allocate to the WiredTiger cache.
- Storage. Be sure you have sufficient I/O bandwidth. Performance depends on good storage quality. Solid state drives (SSDs) are often a great choice because seek-time is significantly reduced. SSDs also provide more gradual performance degradation if the working set no longer fits in memory. If using disk arrays, we recommend using RAID-10 as RAID-5 and RAID-6 do not provide sufficient performance. RAID-O offers good write performance but limited read performance and insufficient fault tolerance.
- Compression. The WiredTiger storage engine decreases storage requirements by as much as 80% using compression. In addition, compression enables much higher storage I/O scalability as fewer bits are read from disk.
- CPU. Faster CPUs lead to better performance. With appropriate sizing and resource allocation using virtualization or container technologies, multiple MongoDB processes can run on a single server without contending for resources. For the sake of availability, multiple members of the same replica set should not be co-located on the same physical hardware.
- Process per host. You should run one mongod process per host.
Running MongoDB on Linux
MongoDB is currently available for Mac OS X, Linux, Windows Server 2008 R2 64bit, Windows 7 (32 bit and 64 bit), Windows Vista, and Solaris platforms. Note that only 64-bit versions of operating systems are MongoDB supported.
Linux is one of the most popular systems for MongoDB deployments so we’ll cover off a couple of recommendations for configuring Linux here. But for more information on specific configurations for Linux and other supported operating systems, file systems and related topics, reference the <a href="http://docs.mongodb.org/manual/administration/production-notes/"target"_blank">MongoDB Production Notes documentation.
For MongoDB applications in production, you should use version 2.6.36 of the Linux kernel or later. We recommend the Ext4 and XFS file systems since MongoDB typically uses very large files. For the Ext4 file system, you need to use version 2.6.23 of the Linux Kernel or later. For the XFS file system, you need to use version 2.6.25 of the Linux Kernel or later.
In terms of configuring Linux for MongoDB, we recommend:
- Turning off atime for the storage volume with the database files
- Disabling hugepages virtual memory pages
- Disabling NUMA in your BIOS or invoking mongod with NUMA disabled
- Making sure that readahead settings for the block devices that store the database files are relatively small as most access is non-sequential
- Synchronizing time between your hosts, an especially important point for sharded MongoDB clusters
Networking and security
This might be stating the obvious but you should always run MongoDB in a trusted environment with network rules that prevent access from all unknown entities. It’s worth your time to read through the <a href="http://docs.mongodb.org/manual/administration/security/"target"_blank">MongoDB Security Tutorials, which offers detailed information on default port numbers for MongoDB, configuring firewalls for MongoDB, VPN and other important security topics.
There are many resources to help you get started. In addition to the <a href="http://www.mongodb.com/lp/white-paper/ops-best-practices"target"_blank">Operations Best Practices white paper, there is a plethora of resources on our website that you can plumb: from the <a href="http://www.mongodb.com/webinars"target"_blank">webinar archives to conference <a href="http://www.mongodb.com/presentations"target"_blank">presentations. You can also take the free, operations and advanced operations online courses on <a href="https://university.mongodb.com/courses/catalog"target"_blank">MongoDB University to get in-depth instruction on operating MongoDB.
Next week, we’ll conclude the series with a look at the topics of security, high availability and backing up your MongoDB deployment.
About the Author - Pam
Pam is a product marketer with over a decade of experience leading marketing programs for B2B technology products. Before MongoDB, she worked at DoubleClick, the ad serving platform company, and then at Google where she worked on marketing display advertising products for over 5 years. Pam earned her BA in History from Barnard College and an MBA from Duke University.