Your app is on the front page of the app store. Hooray! Your service is suddenly flooded with new users and you have a problem that everyone envies: maintaining high performance while your app is under heavy load. Here’s what you need to think about to ensure deployment health.
1. Design Your Schema for Scale You may be surprised that the design of your schema will be a critical component of ensuring performance as your app grows. Your schema should be informed by your application’s use case and query patterns. A good schema will support your common app queries and updates, as well as allow you to create efficient indexes. In contrast, a poor schema can lead to storage fragmentation, make it difficult to efficiently query data and challenging to create indexes. Our rules of thumb blog post is a great resource when modeling your data, as is our Schema Design consultation package.
2. Optimize Your Indexes Many MongoDB users get great performance from a single replica set. Before throwing money at more expensive hardware or diving into sharding, make sure that you’ve got the right indexes in place and that you’ve tuned your queries. Our upcoming webinar on indexing strategies for scale will provide you with lots of useful tips and tricks on this topic.
3. Get the Right Hardware Does your working set fit in RAM? Are you relying on SSDs or HDDs? Are you prioritizing faster CPUs over 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. This presentation on Hardware Provisioning from MongoDB World provides excellent advice using several real-world examples.
4. Look Inside with Monitoring Without visibility into your system, you can’t discover and diagnose issues. To optimize performance properly, first you need to identify what is actually slow! Using the monitoring functionality in MongoDB Management Service along with tools like mtools, mongostat and mongotop, you can visualize performance and identify bottlenecks. Taking it a step further, you can set up alerts in MMS to proactively inform you when key metrics are out of range.
5. Talk to an Expert You’re not the first to face these challenges. Thousands of organizations have built high performance, scalable applications on MongoDB. And we’ve helped most of them. So if you’re worried about performance and scalability, talk to an expert at MongoDB -- at no cost to you.
In our next blog post, we’ll explore methods for scaling out MongoDB.