alex_aldo - Fotolia


DocumentDB vs. DynamoDB: Compare AWS NoSQL databases

Infrastructure and cost management will be key factors if you have to decide between DocumentDB and DynamoDB. Learn how the two AWS document database services differ.

With the release of DocumentDB, AWS now has two NoSQL document database services. DocumentDB, a managed service that launches databases in the cloud, joins AWS' DynamoDB -- a key/value store that also supports document data.

Even though these two products fall within the same database category, they differ in many ways. Let's dig into how to use each of the AWS NoSQL databases, as well as the differences between them.

How to use document databases

An important characteristic of document databases is that they do not impose restrictions on the structure of users' data. Each document, known as a row in a traditional relational database, can have its own data structure. This means you can store multiple documents in the same database and still have flexibility with the data they contain.

When developers prepare to launch a database cluster, they must complete many operational tasks, such as data replication and backup, without disrupting their applications. This is a challenge that DocumentDB aims to solve.

To create a DocumentDB cluster, select a number of parameters, such as the DB instance class, number of nodes, virtual private cloud (VPC) and authentication. After the instances launch, DocumentDB manages the servers and some operational tasks. For example, the service can create backups, upgrade engine versions or increase disk storage as needed. Admins can choose to update cluster capacity, the number of nodes and the instance class.

DocumentDB is compatible with MongoDB, a widely used NoSQL document database. This means most applications that use MongoDB can use DocumentDB without any changes.

With DynamoDB, admins don't have to configure any infrastructure. Instead, they can create a ready-to-use DynamoDB table and configure the read/write capacity settings. Data is automatically replicated across Availability Zones, and DynamoDB automatically scales in on-demand mode.

Just like DocumentDB, data in DynamoDB doesn't have to follow a particular schema. Users can configure additional DynamoDB features, such as Auto Scaling, Global Tables, DynamoDB Accelerator, Point-in-Time Recovery, Encryption and VPC.

Learning curve

DynamoDB involves many specific concepts, such as primary, partition and range keys. These concepts affect scalability and performance. It is essential that developers fully understand the concepts related to keys and indexes as early as possible during application design.

DocumentDB has less of a learning curve, as any developer familiar with MongoDB will know how to use it.

DynamoDB vs. DocumentDB

These AWS NoSQL databases do have some similarities. Both enable portability for data migrations to AWS through the AWS Database Migration Service. Both also offer security features, with encryption at rest via AWS Key Management Service. And they both support auditing capabilities with CloudTrail and VPC Flow Logs for management API calls, as well as CloudFormation.

However, it's critical to evaluate an application's requirements before you decide which AWS NoSQL database is the best fit. DynamoDB is a great fit for applications that access data based on unique keys, as well as for pure key/value use cases. Queries or scan operations are possible, but they can become complex and difficult to scale.

DocumentDB offers more flexible indexing options, such as adding or updating indexes after table creation, and it makes it easier to query data.

The table below highlights some other critical differences between the feature sets:

Compare DocumentDB and DynamoDB
These are some key differences between DocumentDB and DynamoDB.

The cost structure for both of these AWS NoSQL databases is also different. Users can get started with DynamoDB with virtually no upfront cost. DynamoDB's main unit of cost is read/write capacity units. It supports on-demand pricing for these units, as well as provisioned and reserved pricing. Users can manage capacity in small increments -- < $1 per month. The first 25 GB of storage are free. After that, the cost is $0.25 per GB, per month. Backup is $0.20 per GB, per month, and the cost to restore is $0.15 per GB.

On the other hand, DocumentDB users pay per node or EC2 instance. The smallest units of cost are r4.large or r5.large instances, which can amount to about $200 per month, even if they're billed per hour. DocumentDB may support smaller instances in the future, but as of today, only large instance support is available.

Dig Deeper on AWS database and analytics strategy

App Architecture
Cloud Computing
Software Quality