How to Achieve Outstanding Performance With MongoDB Monitoring
How to Achieve Outstanding Performance With MongoDB Monitoring
Databases require monitoring for optimal performance. Here's a guide to achieving proper performance with MongoDB monitoring, like picking the right tech, and identifying characteristics.
Join the DZone community and get the full member experience.Join For Free
Sensu is an open source monitoring event pipeline. Try it today.
The saying “Databases are easy to get started with but hard to master” is as valid today as it’s ever been. MongoDB monitoring done right is key to success as it allows you to get answers for the most important questions, like load characteristics and distribution.
Although MongoDB comes pretty much ready-to-run out-of-the-box, the challenges in mastering MongoDB are no different than that of any other database product. The firsts step in making any database a top performer is to choose the right technology.
Choose the Right Technology
As far as public perception goes, databases should be flexible and powerful enough to perform a wide range of tasks. The truth is though that different databases have different advantages. The old saying, “The right tool for the job” is one of the most overused phrases in IT, but it remains true today. MongoDB really shines in specific areas, but it performs only at average levels in other areas. In contrast to classic RDBMS, NoSQL solutions aren’t designed to be one-size-fits-all persistence solutions.
Identifying the Characteristics
To decide on the right technology, you need to know how your databases will be accessed. Will the database be used mostly for read-, write-, or aggregation tasks? For each use case there’s a “best fit” database.
Ruxit monitors database metrics including numbers of calls and response times and visualizes them according to read-, write-, and delete operations. This is done for all supported database technologies, including both SQL and NoSQL. This simplifies the process of identifying the perfect database fit for your organization.
Microservices and Polyglot Persistence
Microservices-based environments can and should provide dedicated, specialized databases for each service and specific persistence use case. You don’t have to select a single generic database to handle all your services’ use cases—you can get the highest-performing database solution for each of your services.
If you have several services in your ecosystem, you likely have at least one use case that’s ideally suited for MongoDB. By evaluating the load characteristics of your database in combination with the application that’s accessing it, you should have no trouble identifying the best performer for each of your services.
Choosing a technology often depends not only on the technology itself but also on the community and tools that support it. This is why Ruxit monitors so many technologies with a flexible, unified approach.
Two Great Use Cases
I’d like to share two MongoDB use cases that I have experience with. These use cases demonstrate how MongoDB delivered great performance and significant value to an e-commerce solution I worked on.
Pre-Join Your Data
MongoDB doesn’t offer joins like relational databases do. Any joining of data must be done in your application code. But guess what? MongoDB’s ability to work with complex documents instead of flat tables allows you to store readily joined data inside MongoDB!
Our e-commerce solution directly imported as much data as possible from an ERP system. By simply flagging the relevant products in the ERP system, the products were made available for purchase in the online shop. The ERP system’s database was an RDBMS and each product required a couple of joins.
As we knew exactly which data we needed, we selected them in advance and stored them in a pre-assembled document inside MongoDB. When a customer viewed a certain product page in their browser, all the data was collected from MongoDB as a single, pre-assembled data set.
Needless to say, this really improved the performance and responsiveness of the site.
Query Entire Trees as Unified Components
The other perfect fit for MongoDB in our e-commerce project was persisting trees of cascaded categories. Here again, category trees can easily be stored in relational databases—it’s been done for ages, after all.
But a single document in MongoDB can store an entire category tree that can be queried and returned in a single step, same as with the product catalog data use case I mentioned previously.
When to Choose an RDBMS
There are two use cases for which I don’t recommend using MongoDB: two-phase commits and reporting capabilities.
Two-phase commits aren’t supported by MongoDB. If transactional behavior is a must for your use case, go with an RDBMS—two-phase commits are a core competency of RDBMS.
As far as I know, SQL is unmatched in combining different types of data. Usually, reporting isn’t performed in real-time, so performance isn’t much of a concern here. If you need to aggregate across a defined set of data for reporting purposes, go with an RDBMS. SQL databases are blazingly fast at joining data when indices are set correctly.
For the e-commerce solution I worked on, we used a SQL database to keep track of all orders and details. This enabled us to assemble precise reports for products, customers, regions, and any other detail we could think of.
Versatile reporting for you. High performance for your customers.
With MongoDB databases available as online service, it’s easy to migrate to the cloud in stages—moving one service over at a time. And because Ruxit’s unique approach to monitoring enables you to see which data center each of your databases runs on, you can track how performance changes as you migrate individual services to the cloud.
When migrating dozens or even hundreds of services, it’s easy to lose track of the changes you’re making and their impact on your application’s performance.
As one of the pioneers of the NoSQL revolution, MongoDB is clearly a great database solution. And a supportive community and helpful documentation make it easy to get started with MongoDB. You’ve likely read both positive and negative reviews of MongoDB. The bottomline for me is that you won’t know how well MongoDB will perform for your services until you try it.
Benefit From MongoDB Monitoring as a Real Accelerator
And with the right monitoring solution in place, you’ll know the behavior of your apps and databases in production within about five minutes following installation.
Get the best insight into your environment and MongoDB with your free Ruxit 30-day trial!
Published at DZone with permission of Martin Goodwell , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.