DynamoDB is a proprietary NoSQL database service from Amazon. DynamoDB more closely resembles Apache Cassandra than MongoDB. However, peoples often compare DynamoDB with MongoDB. MongoDB is an open source NoSQL database with a AGPL license. DynamoDB is an evolution of Amazon SimpleDB. AWS DynamoDB provides an unique serverless interface which MongoDB does not have. DynamoDB is a cloud service, whereas MongoDB is a open source software application. DynamoDB will abstract all the operations details from the end user. You can control, configure all the options with MongoDB. MongoDB is primarily an in-memory database. When your data sets are larger than the available memory, then MongoDB is a poor choice. DynamoDB actually scales to much larger data sets.
DynamoDB uses JSON for its syntax. Data types used by MongoDB and DynamoDB is the same JSON, but internally MongoDB added some tweak to the JSON data type and names as BSON. Dynamo uses proprietary DQL query language which is very similar to SQL. MongoDB uses a key-value data store with the only data type being its custom JSON implementation. DyanmoDB is a key-value store with no specific implementation functionality thus have a supported data type restrictions.
DynamoDB is vendor locked. Choosing DynamoDB users to choose to remain within the AWS network. As MongoDB is an open-source database, it is capable of running on any platform. We can install MongoDB on a cloud server, on a bare metal server or use as DBaaS. MongoDB is a document database, whereas DynamoDB still uses tables to represent data.
Aggregation operations process data records and return the computed results. Aggregation operations group can perform a variety of operations on the grouped data to return a single result. MongoDB provides three ways to perform aggregation – aggregation pipeline, map-reduce function and single purpose aggregation methods. DynamoDB does not provide an aggregation pipeline. MongoDB is schema-free whereas DynamoDB is schema-less. That means we can enforce schema validations on MongoDB but not on DynamoDB.
The maximum item size in DynamoDB is 400 KB whereas MongoDB BSON document size is of 16 megabytes. Also, MongoDB provides the GridFS API. GridFS is a specification for storing and retrieving files that exceed the BSON-document size limit of 16 MB. MongoDB is part of open source stacks such as MEAN/MERN. They are portable to any hosting environment and not limited to Amazon.
DynamoDB with MongoDB addresses different use cases. They can not be fully compared head to head.