When comparing MongoDB vs DynamoDB, the Slant community recommends MongoDB for most people. In the question“What are the best NoSQL databases for web applications?” MongoDB is ranked 5th while DynamoDB is ranked 12th. The most important reason people chose MongoDB is:
Miles above other databases in educational resources.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Perfect documentation and tutorials
Miles above other databases in educational resources.
Pro Great speed
MongoDB queries can be very fast because the data is usually all in one place and can easily be retrieved in a single lookup. But this is true only when the data is truly a document. When it's trying to emulate a relational model it starts to become really slow because it may have to perform many independent queries to retrieve a single document.
Pro Uses JSON
As Node.js uses JavaScript there's no need to map the returned JSON data from MongoDB, as JavaScript is a superset of JSON. Essentially solving object-relational impedance mismatch by its very nature. Working with JSON is also easier overall as it more easily fits into how you would represent data on the client.
Pro Doesn't require a unified data structure
Mongo is very flexible in that it doesn't require a unified data structure across all objects. So it's rather easy to use.
Pro Easy to scale
MongoDB has powerful sharding and scaling capabilities for when the data stored in the database gets so large that a single machine may not be able to store all of it. Sharding solves this problem through horizontal scaling. Mongo gives developers the ability to easily and painlessly add or remove as many machines as needed.
Pro Free tier
DynamoDB offers a free tier which allows up to 40 million database operations a month for free.
Pro Trigger tasks (AWS Lambda) on write
When a new record is written, it can trigger one or many AWS Lambda functions. With Lambda functions in Java, JavaScript, and Python and the other con of "Easy integration with other Amazon services", Lambda functions may be all you need to process the events. This is particularly useful for creating projections (often as other DynamoDB tables) and other read models in a CQRS pattern.
Pro High uptime
Data hosted on DynamoDB is automatically replicated across multiple AWS availability zones, this way the data is protected from any malfunction that may cause loss and it also ensures high uptime.
Pro Easy integration with other Amazon services
Since it's part of AWS, like with other services that Amazon provides, it's very easy to integrate DynamoDB with any other AWS service that you may be using.
Cons
Con Reported to lose or corrupt data
MongoDB is famously known for leaking and losing data over time.
Con Document Stores may be not suited for relational data
MongoDB has no JOIN, all relations are supposed to be resolved client-size which entails additional requests to the server.
Con Need many search features
Though it is possible to index and search text in documents in MongoDB 4.0 in multiple languages. The indexing and search is not as powerful as for example Elastic Search. For instance not being able to search for only parts of words.
Con No specific features for Event Sourcing
DynamoDB is just a general purpose NoSQL database; hence, there are no features specific to the domain of Event Sourcing, such as event ordering or projections. As a developer, you will need to decide how to implement these.
Con Poor documentation
In true AWS fashion, the documentation for DynamoDB is not top notch. While the learning curve is generally very soft and it's not hard to learn, you need to have at least some experience with cloud and database management to be able to start using DynamoDB and understand the documentation.