Navigation

Subscribe

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!

MongoDB

I've been taking an online class in MongoDB. It has been a great experience. I am impressed with the quality of online instruction, their LMS, and the pacing of the course. It's a quick course (3 weeks), but it's chock full of labs and lectures where you can try out and learn the various aspects of MongoDB. In this post I'm going to be discussing some of the things I like about their NoSQL system.

MongoDB Atlas Cluster

Atlas

Atlas is really the backbone of the NoSQL architecture for MongoDB. It's where you start using MongoDB. Atlas lets you setup "clusters" which are redundant nodes used to access your data. They use AWS for storage (S3) and computation (EC2 + EBS), but not RDS because MongoDB is a NoSQL and scales horizontally rather than vertically.

The redundant nodes ensure that your data will be able to be accessed in all sorts of situations. Not only is your storage and computation redundant through Amazon's policies for their services, but you can have 3-7 nodes from which to connect and alter your data. This means that it would take 3-7 separate physical sites to have major connectivity issues for you to lose immediate access to your information. And if something were to happen to the nodes, you could still retrieve your data from S3 and EBS images which also have redundant storage. I suppose if you were really paranoid you could setup Atlas to use your own AWS information then setup versioning in S3 with a lifecycle to roll over into infrequently accessed storage, then finally cold storage...but who would be that obsessed with keeping all of those 1s and 0s intact?

So it's a good and automated setup. I feel reasonably secure with my fake databases that were given to me for my course. But what else does it do? For my purposes, Atlas is a good setup utility and has some monitoring features. You can monitor disk usage, network usage, connections, setup alerts, add users...all of your basic and boring sysadmin stuff.

Compass

MongoDB Compass
Compass is a great tool if you don't want to be staring at terminal screens any longer than you have to. It's MongoDB's graphical client, and aint it purdy? You can peruse databases, inspect collections, search data, add data one document at a time, and do all sorts of other good things.

The main uses I found for Compass were to quickly inspect data, and to search for inconsistencies in value types. You can see in the above image that it displays information nicely, and will even draw your attention when a field has different value types between different documents. If, for example, most of your document id's are stored as 32-bit integers and you have a few stored as strings, you can clearly see it on the graph. The minority is graphed in grey with the majority in black. Mousing over the value types displayed in Compass will tell you how many items are shown in that value type.

You can quickly search through the current collection using the search function at the top. All searches need to be done in JSON format, though (use those handlebars). I've picked up on json, it's pretty easy with a decent IDE (below) although it gets messy when trying to parse through large files using nano or any other text-editor.
JSON

Compass doesn't support all of the MongoDB functions currently, though. Many operations that involve scripting, altering multiple files, removing files based on search criteria, and a lot of data-cleaning functions are still not supported. For that, we are left with the MongoDB Shell (Mongo). I was a little perturbed that they didn't maintain a PPA for Ubuntu, so rather than running it in bash I downloaded their windows command-line client.

Connecting to the shell is pretty easy. Atlas gives the commands you need to connect to whichever node you wish, and copy-paste works with a few tweaks to get your password set and identify the collection you want to start with. If I were to regularly use this, I would probably setup a shell script to connect because it got a little cumbersome having to connect to Atlas everytime to get the wonky url right to connect. That being said, it's a decent program.

Overall

I like MongoDB. If it were to be used in a professional, high-use situation I think it would definitely be worth the cost. I'm going to keep using it because I like the ability to easily access and edit my data from an easy-to-use graphical interface, monitor it from a browser-based service, and run scripts and large batch-processes from a command line. I'm sure there are other NoSQL services that accomplish this, but MongoDB really has their stuff together (good documentation and support, too).

Comments: