dynamodb Vs. Mongodb

This series of posts analyzes how specific NoSQL databases stack up against one of the most popular NoSQL databases, MongoDB. We've covered the following comparisons so far:

In this post, we'll see how Amazon's DynamoDB compares to MongoDB.

If you're already using the AWS stack and you need a NoSQL database, then DynamoDB might be right for you.

 Who Uses These Databases?

Here are examples of companies using these databases:

DynamoDB: Amazon, Samsung, Snapchat, Netflix, Electronic Arts, New York Times, AdRoll, HTC, Dropcam, Twiitch, Shazam, Twilio, Localytics and Clubhouse. You can see the full list here.

MongoDB: Google, UPS, Facebook, Cisco, eBay, BOSH, Adobe, SAP, Forbes, and many more. You can see the full list here.

 What About Database Structure?

DynamoDB: DynamoDB uses tables, items and attributes as the core components that you work with. A table is a collection of items, and each item is a collection of attributes. DynamoDB uses primary keys to uniquely identify each item in a table and secondary indexes to provide more querying flexibility.

MongoDB: MongoDB uses JSON-like documents to store schema-free data. In MongoDB, collections of documents do not require a predefined structure and columns can vary for different documents.

MongoDB has many features of a relational database, including an expressive query language and strong consistency. Since it is schema-free, MongoDB allows you to create documents without having to create the structure for the document first.

A useful comparison with relational database management systems (RDBMS) in which you have:

Table | Column | Value | Records

In comparison, in MongoDB you have:

Collection | Key | Value | Document

This means that collections in MongoDB are like tables in RDBMS.

Documents are like records in a RDBMS. Documents can easily be modified by adding or deleting fields without restructuring the entire document.

 Are Indexes Needed?

Indexes give you access to alternate query patterns, and can speed up queries.

DynamoDB: In DynamoDB, you can create and use a so-called secondary index for similar purposes as in RDBMS. When you create a secondary index, you must specify its key attributes and after you create it, you can query it or scan it as you would a table. DynamoDB does not have a query optimizer, so a secondary index is only used when querying or scanning.

MongoDB: Indexes are preferred in MongoDB. If an index is missing, every document within the collection must be searched to select the documents requested by the query. This can slow down read times.

 How Are Their Queries Different?

Selecting records from the customer table



TableName: "customer"




Inserting records into the customer table



TableName: "customer",

Item: {

"cust_id": "appl01",

"branch": "main",






cust_id: 'appl01',

branch: 'main',

status: 'A'


Updating records in the customer table



TableName: "customer",


"custage": age


UpdateExpression: "set branch = :a",








{custage: { $gt: 2 }},

{$set: { branch: 'main' }},

{multi: true}


 Where (And How) Are These Databases Deployed?

DynamoDB: DynamoDB was written in Java, though web pundits speculate that it may actually be written in Node.js.

DynamoDB supports the following programming languages: Java, JavaScript, Swift, Node.js, .NET, PHP, Python.

MongoDB: MongoDB was written in C++. It is available on Linux, OS X, Solaris, and Windows.

MongoDB supports the following programming languages: Actionscript, C, C#, C++, Clojure, ColdFusion, D, Dart, Delphi, Erlang, Go, Groovy, Haskell, Java, JavaScript, Lisp, Lua, MatLab, Perl, PHP, PowerShell, Prolog, Python, R, Ruby, Scala and Smalltalk.

 What Types Of Replication / Clustering Are Available?

DynamoDB: AWS provides a cross-region replication solution based on an open source command line tool. For more information, please refer to the detailed instructions on GitHub.

The DynamoDB cross-region replication solution uses the Amazon DynamoDB Cross-Region Replication Library. This library uses DynamoDB Streams to sync DynamoDB tables across multiple regions in near real time. When you write to a DynamoDB table in one region, those changes are automatically propagated by the Cross-Region Replication Library to your tables in other regions.

MongoDB: MongoDB has a single-master replication with built-in auto-election. This means you can have a second database set up and it can be auto-elected if the primary database becomes unavailable. With MongoDB replica sets, one member is primary and any replicated databases have a secondary role. While the auto-elect process happens automatically, it can take 10 to 40 seconds for it to occur. While this is happening, you cannot write to the replica set.

 Who's Currently Behind The Databases?

DynamoDB: In September 2013, Amazon made available a local development version of DynamoDB so developers can test DynamoDB-backed applications locally. It is a part of Amazon's AWS.

MongoDB: MongoDB was started in 2007 by 10gen, which created the product based on the word “humongous”. In 2009, it was released and 10gen later changed their company name to MongoDB, Inc. MongoDB, Inc. provides development of the software and sells their enterprise solution.

 Who Provides Support?

DynamoDB: Amazon provides support via the Community Support Forum, ServerFault, and StackOverflow. Enterprise support is also available.

MongoDB: MongoDB, Inc offers a support community via the Community Support Forum, ServerFault, and StackOverflow. Users can also get enterprise support 24x7 with optional lifecycle via enterprise grade support.

 Who Maintains The Documentation?

DynamoDB: Amazon maintains the documentation, and makes it available online.

MongoDB: MongoDB, Inc. maintains the MongoDB documentation, and it can be found here. From there, you can find information about the MongoDB Server, Atlas (database as a service), cloud manager for hosted MongoDB, and Ops Manager.

 Is There An Active Community?

DynamoDB: The DynamoDB community offers sample applications, drivers, tools and extensions.

MongoDB: The MongoDB community offers information about webinars, events, user groups and the MongoDB University.

 Which Database Is Right For Your Business?

DynamoDB: DynamoDB is popular in the gaming industry as well as in the internet of things (IoT) industry. If you're already using the AWS stack and you need a NoSQL database, then DynamoDB is a no-brainer. Keep in mind that you can’t have embedded data structures like you can with MongoDB.

MongoDB: MongoDB can be a great choice if you need scalability and caching for real-time analytics; however, it is not built for transactional data (accounting systems, etc.). MongoDB is frequently used for mobile apps, content management, real-time analytics and applications for IoT. If you have a case with no clear schema definition, MongoDB can be a good choice.

You’ll be fine with either of these two databases, but the best database for your business will likely depend upon your dev team and the applications you use. But if you're already using the AWS stack and need a NoSQL database, then you should first review what DynamoDB has to offer and how well it works for your use case. 

Get a free consultation with a data architect to see how to build a data warehouse in minutes.
Request Demo
Read more in:
Share this post:

Work smarter, better, and faster with monthly tips and how-tos.