The Top Three Alternatives to MongoDB in 2019
JAM Stack, PostgreSQL, and Amazon’s DynamoDB are all competitive alternatives to MongoDB
NoSQL databases originated in 2009 as sites like MySpace scaled up:
NoSQL came into existence because the databases at the time couldn’t handle the scale required.
Why People Are Leaving MongoDB
In general, NoSQL has significant differences from previous database architecture that can cause lost records and decreased performance:
NoSQL abandoned some of the core features of databases that make them highly performant and easy to use.
The Guardian Famously Left MongoDB
The online publication and British newspaper The Guardian received over 100,000 views on its November 2018 article about leaving MongoDB:
Bye bye Mongo, Hello Postgres | Digital blog
At the Guardian, the majority of content - including articles, live blogs, galleries and video content - is produced in…
In it, the developers who made the switch reveal that their team had problems with OpsManager — Mongo’s database management software — and that Mongo’s support agents were not much help during two outages.
I took a deep dive into the reasons the publication chose to move from MongoDB to PostgreSQL in Better Programming:
The Three Alternatives to MongoDB
While many people continue to use Mongo, there are many alternatives available for software developers and database engineers, such as:
- JAM Stack: Fast, secure, and dynamic web sites served without web servers.
- PostgreSQL: SQL database known for its reliability, features, and performance.
- DynamoDB: NoSQL database created by Amazon Web Services (AWS)
These three options are the current best alternatives to MongoDB. We’ll review the pros and cons of each choice in detail in the next section.
MongoDB Alternative #1: JAM Stack
JAM Stack could even replace a document database as long as the data could be moved to a whole lot of JSON files written in Markdown.
When using JAM Stack, the entire application is then compiled (or built), usually with a tool like Gatsby.
Unfortunately, that means that any change requires the site to be rebuilt.
On the other hand, dynamic content can change in real-time if it is accessed through an API, like comments handled through Disqus.
Advantages of JAM Stack
Lightning-fast content delivery is the biggest advantage of JAM Stack, because there is no server — the entire app is running client-side.
At the same time, there is also maximum SEO — because the app was pre-compiled, it is being served as static pages, not generated on-demand.
Another advantage to JAM Stack is minimal hosting costs. For example, static pages are basically free to host at AWS.
Disadvantages of JAM Stack
Every single change has to be re-built. That means the app needs to be recompiled before that change is going to be available live online.
And, the larger the website, the longer the build time. Every time.
Thus, JAM Stack is usually not seen as a good fit for apps requiring frequent publication, huge amounts of data, or live editing of data records.
MongoDB Alternative #2: PostgreSQL
Advocates of using SQL cite the ongoing prevalence of SQL architecture and superior ability to perform operation analytics on SQL databases:
[R]elational databases have evolved. They can can handle nearly all of the workloads, with the scalability, reliability, and availability requirements that modern applications demand.
In other words, if a SQL database can scale, then it is preferable to NoSQL.
PostgreSQL (also called Postgres) is a popular, free SQL database that calls itself “the world’s most advanced open source database” on its website.
Advantages of PostgreSQL
PostgreSQL is a powerful software that has been developed continuously for over 30 years. Lots of people use it and it has a vibrant community.
Disadvantages of PostgreSQL
Using SQL inherently adds complexity to any project. It is an entirely new programming language for a team to use on a day-to-day basis.
It can be difficult to migrate from NoSQL to SQL. They are fundamentally a different type of database structure. NoSQL is a document store with key-value pairs, while SQL is composed of tables and rows.
One option, and what The Guardian used in their migration, is the
JSONb column type in PostgreSQL. However, using JSON blobs feels kind of like a hack, like shoehorning a NoSQL database into a SQL format.
MongoDB Alternative #3: DynamoDB
That means migration from MongoDB to DynamoDB is really pretty easy.
Advantages of DynamoDB
DynamoDB is the flagship NoSQL database on AWS, so its inherent advantage is the AWS platform’s cost, speed, and reliability.
The big advantage of DynamoDB for anyone currently using Mongo is that users can perform a live migration from MongoDB straight to DynamoDB.
The best part is there is no infrastructure to manage — Amazon handles it.
Disadvantages of DynamoDB
If I am of the opinion that NoSQL has too high of a probability of losing records, then DynamoDB is not going to be a good choice for me.
DynamoDB can have scalability problems, like those associated with so-called hotkeys, records that are assessed much more frequently than others.
In addition, compared to MongoDB, DynamoDB supports less complex data types and is an AWS-exclusive product.
“Containers won the battle, but will lose the war to serverless.”
JAM Stack is one of coolest technologies out today. It is absurdly fast, accessible, and SEO-friendly, plus static files are free to host on AWS.
However, JAM Stack is only the right option for apps that have the luxury of being able to have a build step and recompile every change.
If you ask me, I would argue that even very large websites could be built on a JAM Stack through scheduled compilations, say hourly. JAM Stack is rad.
It might not work for a news site, but many dynamic sites do not need content updated more frequently than that, and static sites surely do not.
SQL vs. NoSQL
If needing a compilation step is a deal-breaker for a project, then it comes down to SQL vs NoSQL: PostgreSQL or DynamoDB.
PostgreSQL does not have to be hosted on Amazon, though it can be hosted at Amazon RDS. DynamoDB was developed by and is exclusive to Amazon.
SQL databases are inherently more powerful but also more complicated. Their strength is in business analytics and search.
NoSQL databases are easier to set-up and sufficient for many projects. That’s why The Guardian considered DynamoDB for their 2.3m articles.
In the end, they chose PostgreSQL because DynamoDB did not offer encryption at rest back in 2017, but they may well have made a different decision if they were considering a move from MongoDB today.
JAM Stack (serverless architecture) is a wonderful option, especially for any site that is mostly static, and is also a great technology to be aware of.
PostgreSQL has a huge community and offers all the power of SQL in a reliable, feature-rich, open-source package with great performance.
DynamoDB is a drop-in replacement for MongoDB that gives you scale, security, and speed without needing to maintain any infrastructure.
- A good way to understand JAM Stack is the site WTF is JAMstack?:
The following tips will help you leverage the best out of the stack. Content delivery network Since all the markup and…
- The website PostgreSQL Tutorial teaches about what makes “PostgreSQL stand out from other database management systems”:
What is PostgreSQL
Summary: in this tutorial, you will learn about PostgreSQL and features that make PostgreSQL stand out from other…
- The CMARIX TechnoLabs blog explains the benefits of DynamoDB:
Benefits of Amazon DynamoDB
For handling Data storage requirements in the IT World, you need to depend upon the Database management systems (DBMS)…
- If you ask the people at Mongo, MongoDB is way better than DynamoDB: