mongodb

Because of the database abstraction layer that was added in Drupal 7, it is fairly convenient to use a variety of database servers for the backend of your Drupal software. While the term "database abstraction layer" does sound rather sophisticated, and the code involved is certainly not insignificant, in layman's terms what this system does is provide a way for a Drupal developer and Drupal modules to work with its database without generally having to be concerned with what type of database it is.

Generally speaking though, this works very well with relational model databases, such as MySQL. These types of databases are composed of various tables which are connected by relationships of keys. The relational model of databases is a very successful one and has been studied and improved for decades now. Schemas and relational integrity are important features of this model that makes it useful for content management systems.

There are other types of database models though, most having been around just as long. NoSQL is a popular classification that is often used to refer to non-relational database types, and MongoDB is a somewhat newer database system built around document collections that fit into this category.

Not storing data in tables with rows and columns, MongoDB keeps it in documents that have a JSON-like format. As well, these documents aren't bound by a strict universal schema, so your data can easily change over time without requiring retroactive edits to older documents. Some of the key qualities that have attracted users to MongoDB are its built-in performance enhancing features, such as high availability with replica sets and load-balancing with horizontal sharding.

That is quite obviously a very cursory review of the technical aspects of MongoDB, but you can read in more detail about it on their main website.

While document-based databases are not new, the release of MongoDB several years ago created quite a stir and made developers very interested in finding uses for it in their applications, usually to take advantage of its vaunted performance qualities.

Can you use MongoDB with Drupal?

The short answer is "yes", sort of. Drupal 7 saw the release of the MongoDB module. An important thing to realize though is that this integration does not allow for completely switching to using MongoDB as the database for your Drupal installation. Despite the utility of the Drupal database API we previously mentioned, there are still aspects of how a content management system like Drupal works that don't lend themselves well to the document storage nature of MongoDB. For Drupal 7 a significant number of components of Drupal can still be stored by MongoDB, and for Drupal 8 possibly, even more, when the work on the module is completed.

See the table on the module project page to review which Drupal features can be converted to use MongoDB.

So, will you see performance boosts to your Drupal website by just integrating MongoDB to store various components, like entities or blocks? It is possible to gain a small performance increase, but this is not guaranteed, is almost assuredly dependent on the nature of your website and its content.

A document storage database like MongoDB is much better suited at server lots of "reads" very quickly and allows for scaling to multiple servers very easily. So, if you have a large website that servers an enormous amount of content to be read (and not updated) by users, it might be advantageous to use a solution like MongoDB.

However, if you have a lot of interactive content with editing and updating, so writes to the database, then MongoDB may not offer any improvements and actually may cause problems with duplication if not properly managed.

The important thing to realize here is that many popular technologies are not automatically a good solution simply because they are being talked about and used by well-known tech luminaries. Most tools have a use-case that matches their features, and MongoDB is no different. Be sure to learn more about this database system before determining if it will be a useful addition to your project.