Over a million developers have joined DZone.

12 Tips for Going into Production with MongoDB

· Java Zone

Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management, brought to you in partnership with Stormpath.

Originally written by Eric Holzhauer

Are you going into production with MongoDB? Don’t flip the switch yet! Read these 12 tips from our expert support engineers to make your launch a success.

Develop It Right the First Time

1. Make Your Schema Works For You
Does your schema fit your queries? Are there holdovers from "relational world" that don’t belong in a document structure? MongoDB’s dynamic schema makes it easy to change structure as your needs evolve, but getting it right to start saves time.

2. Optimize Your Indexes
MongoDB supports many different types (link is external) of secondary indexes. What do you need? Are your indexes optimized for your most common queries?

3. Be Prepared for Sharding
You don’t need to shard right away, but you should have a plan. Shard before you run out of capacity! MongoDB supports multiple sharding policies (link is external) to match your query pattern. You have the flexibility to shard on any key, so think about which will best serve your use case. We can help you plan for sharding.

4. Set Your Write Concern
MongoDB gives you a lot of flexibility (link is external) in managing write guarantees. The default is Acknowledged, but you can set write concern to Unacknowledged for maximum speed, or dial it all the way up to require a write to all replicas across multiple data centers for maximum data resilience.

For Smooth-Running Ops

5. Choose the Right Hardware
Does your working set fit in RAM? Are you relying on SSDs or HDDs? Are you prioritizing faster CPUs or more cores? Is your storage local or remote? Are you virtualizing or running on bare metal? The right hardware will optimize performance, while the wrong hardware can lead to problems down the line.

6. Enable High Availability & Disaster Recovery
MongoDB maintains multiple copies of data in self-healing replica sets (link is external). What level of failure do you need to be able to tolerate? One server giving up? A whole rack catching on fire? A whole data center losing power in a hurricane?

7. Back Up Your Data
Replication takes care of the problem if a node fails. But what if your application starts writing over data? What if someone fat-fingers it and drops a collection? Have a backup strategy in place, take consistent backups, and make sure you practice restoring from backup! MongoDB Management Service (MMS) provides automated backup and point-in-time recovery.

8. Monitor Your Deployment
MMS also makes it easy to watch over how MongoDB is running. Catch potential problems before they get serious! MMS makes it easy to check performance statistics, deploy new clusters, and take care of other operations tasks.

9. Keep Your Data Secure
Are you handling sensitive, classified, or personally identifiable information? Do you need to comply with regulations or internal policies for security? MongoDB Enterprise offers advanced security options, including access controls, encryption and auditing.

10. Tune Up Your Performance
Many factors can affect performance with MongoDB, including everything listed here! Tweaking some of your settings can give you serious performance returns. Conversely, having the wrong setup can cause bottlenecks that could be hard to diagnose. Our consultants can help you optimize performance.

11. Be Ready for Upgrades
Automation, an upcoming feature of MMS, makes it easy to upgrade your whole deployment with a single click. Hot upgrades with no application downtime, without the time and effort of doing it manually!

12. Get Support
If your application is mission-critical (and what applications aren’t?), rely on the peace of mind that comes with Production Support. Our SLAs ensure that expert engineers will respond quickly to your issues and work with you to resolve them. MongoDB Enterprise comes with support or you can sign up for standalone Production Support.


For more information, download our Ops Best Practices Guide. For answers to your questions and to ensure that production goes smoothly, get in touch!

The Java Zone is brought to you by Stormpath—a complete, pre-built User Management API. Want to learn how to use JWTs to protect microservices from CSRF and more? Check out this on-demand webinar with our Java Developer Evangelist, Micah Silverman.

Topics:

Published at DZone with permission of Francesca Krihely, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}