Why use MongoDB?
The main and the biggest benefit of MongoDB is that it is a no-fixed-schema database architecture. It is a NoSQL database so that’s kind of obvious. The next reason for choosing MongoDB is because of its document store nature which is very useful in multiple use cases. But we already got that covered in our ‘Choosing the Right NoSQL Database Type for App Development’ post. So the question comes why use MongoDB as your choice of Document Store Database. Here are a few reasons why:

Performance in Ad Hoc Queries
The biggest advantage of MongoDB over other databases is its performance under pressure especially when handling ad hoc queries on data that are usually updated in real time. MongoDB can retrieve specific fields, ranges, locations, values, and even respond well to regular expression queries. MongoDB uses SQLesc kind of query language so it is easy to learn and its capability in handling dynamic queries sets it apart from CouchDB which requires setting up views first.

In an experiment that we carried out on MongoDB performance for one of our projects we found that MongoDB can handle up to 4 queries per millisecond easily. For this experiment we used a Linode server with following configurations

4 core 2.80GHz each
4096 MB RAM
We found that at frequencies of 2 queries per millisecond, MongoDB was performing great with an average output time of 5ms. However at the frequency of 4 queries/ms, the output time started to increase and the average output time increased. For some queries the output time was even as high as 1200ms.

MongoDB is most suited for applications which require consistent data presentation for users. Therefore if your main aim is availability of database for just data entry during data visualization, consistency is not an issue (like for example in a social network), then you can go with CouchDB or some other counterpart. However before doing that take performance into consideration as well.

Location Based Query Feature
MongoDB is the best choice if you are going to build an app that has location based features like location finding, location based event tracking etc. MongoDB is the only free document storage NoSQL database with inbuilt geo-spatial features.

The database can be scaled horizontally very easily. The database scalability is handled via innovative Sharding which is pretty unique in its own. We especially liked MongoDB’s performance in replicating the data and creating replica set to increase availability and consistency. The database is smart enough to handle replica operation failures while still coming out with consistent values.

Load balancing on Multiple Servers
Most document storage databases are equipped with features to allow scalability over multiple servers. Unlike SQL databases, multiple server based databases can be easily clustered in NoSQL. MongoDB is no exception but we found its performance on multiple server based apps better in comparison with CouchDB but again our use case was biased towards MongoDB in that experiment.

JSON based document storage schema
MongoDB uses JSON (JavaScript Object Notation) based document storage schema called BSON. The main benefit of this format comes in use-cases where you would have to integrate your app with other platforms. For example YouTube API outputs its data in JSON format so MongoDB is great in handling those request.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store