LAUNCHMongoDB 8.3 is built for the sub-100ms retrieval & zero downtime AI demands. Read blog >
AI DATAStop fighting your data layer. Get the memory & retrieval agents need to scale. Read blog >

Comparing DynamoDB and MongoDB

Get Started Free

Table of Contents:

Quick Comparison Table

MongoDBDynamoDB
Freedom to Run AnywhereDeploy anywhere: Laptop to mainframe, on-premises to hybrid cloud to managed cloud service; MongoDB Atlas database as a service can be deployed on AWS, Azure, and Google CloudOnly available on AWS: No support for on-premises deployments; Locked in to a single cloud provider
Data ModelJSON based document store: Up to 16MB document size; Regular JSON data types and advanced BSON types: (int, long, date, timestamp, geospatial, floating point, and decimal128)Limited key-value store with JSON support: Maximum 400KB record size; Limited data type support (number, string, binary only) increases application complexity
QueryingRich query language: Query by single keys, ranges, faceted search, JOINs and graph traversals, and geospatial queries; Complex aggregation stages resembling UNIX pipes for data analytics; On-demand materialized views for fast analytic queriesKey-value queries only Primary key can have at most 2 attributes, limiting query flexibility; Non-operational queries (analytics, search, etc.) require replicating data to another AWS service, increasing cost and complexity
IndexingRobust / Easy to develop against: No extra cost to index your data; Create hash, compound, unique, array, partial, TTL, geospatial, sparse, text, and wildcard indexes to support any query pattern; Indexes are strongly consistent with underlying data, always returning the latest results; Define secondary indexes on any field, at any time, including deeply nested array elements; Performance Advisor recommends indexes based on query patterns with click-to-create functionalityLimited / Complex to manage: Indexes are additional tables that must be sized, billed & provisioned separately from data; Hash or hash-range indexes only; Global secondary indexes (GSIs) are eventually consistent, forcing applications to handle stale data; Local secondary indexes (LSIs) can be strongly consistent, but must be defined when a table is created; GSIs can only be declared on top-level item elements. Cannot index nested fields, sub-documents, or arrays, making complex queries impossible; Maximum of 20 GSIs & 5 LSIs per table
Data IntegrityStrongly consistent by default: Easy to reason about—always see current data; Native schema governance and data validation; ACID transactions apply to documents, indexes, and backups; 1,000 operations per transaction (executing within 60 seconds by default)Eventually consistent by default: Complex—need to handle stale data in application; No data validation—must be handled in application; Single-region strongly consistent reads cost 2x more than eventually consistent ones and are not supported in GSIs; Transactions cost 2x more than regular writes and only apply to single-region table data—not to indexes or between regions; Maximum of 100 writes per transaction
Monitoring and Performance TuningTransparent: MongoDB Atlas exposes 100+ metrics on database performance; MongoDB Atlas Performance Advisor recommends optimal indexes and suggests schema changes; MongoDB Compass enables schema visualization and graphical query constructionBlack-box: Fewer than 35 metrics limit visibility into database behavior; No tools to visualize schema or recommend indexes
BackupOn-demand, continuous, or snapshot backups: MongoDB Atlas provides fully managed continuous backups, with filesystem snapshot backups for lower costOn-demand or continuous backups: Additional charge to restore backups
PricingConsistent: MongoDB Atlas pricing is based on RAM, I/O, and storage; On-premises pricing is based on number of nodes or RAM sizingHighly variable: Throughput-based pricing; A wide range of inputs may affect price. See Pricing and Commercial Considerations
Multi-Region offeringComplete: Strong conflict resolution; Sub-15 sec. multi-region auto-failover; Multi-document ACID transactions; MongoDB Atlas’ zone sharding allows users to distribute data territorially, providing them full data sovereignty controlPartial: Hard-coded last-write-wins conflict resolution, which might lead to data loss; No multi-region auto-failover; No ACID guarantees between regions; DynamoDB Global Tables replicate all data to every region where the table is present, which might lead to data sovereignty issues that require workarounds
Support for non-operational workloadsYes: MongoDB Atlas supports analytics, time series, full-text, and vector search workloads without needing third-party services, an ETL pipeline, and data duplication; Workload isolation prevents different types of workloads from impacting each other’s performancesNo: Reliance on other AWS services for non-operational workloads, which increases cost and complexity while aggravating vendor lock-in

 

What is DynamoDB?

DynamoDB is a proprietary NoSQL database service built by Amazon and offered as part of the AWS portfolio. DynamoDB is known for providing performance consistency at scale.

What is MongoDB?

MongoDB is an open, document (non-tabular) database built by MongoDB, Inc.

MongoDB stores data in flexible, JSON-like records called documents. This model maps to objects in application code, making data easy to work with for developers. Related information is typically stored together for fast query access through the MongoDB query language.

Terminology and Concepts

Many concepts in DynamoDB have close analogs in MongoDB. The table below outlines some of the common concepts across DynamoDB and MongoDB.

 

DynamoDBMongoDB
TableCollection
ItemDocument
AttributeField
Secondary IndexViews

 

Deployment Environments

MongoDB can be run anywhere—from a developer’s laptop to an on-premises data center to any of the public cloud platforms. As mentioned above, MongoDB is also available as a fully managed cloud database with MongoDB Atlas. This model is most similar to how DynamoDB is delivered.

In contrast, DynamoDB is a proprietary database only available on AWS. While a downloadable version of the database is available for prototyping on a local machine, the database can only be run in production in AWS. Organizations looking into DynamoDB should consider the implications of building on a data layer locked into a single cloud vendor.

Data Model

MongoDB stores data in a JSON-like format called BSON, which allows the database to support a wide spectrum of data types including dates, timestamps, 64-bit integers, and Decimal128. MongoDB documents can be up to 16 MB in size; with GridFS, even larger assets can be natively stored within the database.

MongoDB provides built-in schema validation. Users can enforce checks on document structure, data types, data ranges, and the presence of mandatory fields. As a result, DBAs can apply data governance standards, while developers maintain the benefits of a flexible document model.

DynamoDB is a key-value store with added support for JSON to provide document-like data structures that better match with objects in application code. An item or record cannot exceed 400KB. Compared to MongoDB, DynamoDB has limited support for different data types. For example, it supports only one numeric type and does not support dates. As a result, developers must preserve data types on the client, which adds application complexity and reduces data re-use across different applications. DynamoDB does not have native data validation capabilities, forcing developers to implement it manually.

Queries

MongoDB's API enables developers to build applications that can query and analyze their data in multiple ways—by single keys, ranges, faceted search, graph traversals, JOINs and geospatial queries through to complex aggregations, returning responses in milliseconds. Complex queries are executed natively in the database without requiring additional analytics frameworks or tools. This helps users avoid the latency increase provoked by syncing data between operational and analytical engines.

DynamoDB supports key-value queries only. For queries requiring aggregations, graph traversals, or search, data must be replicated into additional AWS technologies, such as OpenSearch or Redshift, increasing latency, cost, and developer work. AWS offers “Zero-ETL” integrations to connect additional AWS services with DynamoDB. However, these integrations are available in a limited number of regions, and the cost and complexity sprawl derived from managing disparate services still remains.

Indexes

MongoDB ensures fast access to data by any field with full support for secondary indexes. Indexes can be applied to any field in a document, down to individual values in arrays. Supported indexing strategies such as compound, unique, array, partial, TTL, geospatial, sparse, hash, wildcard, and text ensure optimal performance for multiple query patterns, data types, and application requirements. Indexes are strongly consistent with the underlying data.

DynamoDB indexes are views of their underlying tables (base tables). They are queried against directly and, therefore, they require to be sized and provisioned accordingly, which may result in unforeseen issues at runtime. DynamoDB indexes can only be defined as hash or hash-range; more advanced indexing strategies are not supported.

DynamoDB supports two types of indexes: Global secondary indexes (GSIs) and local secondary indexes (LSIs). Users can define up to five LSIs and 20 GSIs per table.

LSIs can be queried to return strongly consistent data, but must be defined when the table is created. They cannot be added to existing tables nor removed without dropping the table. For these reasons, GSIs are usually the go-to solution for querying non-primary fields.

GSIs, which are eventually consistent with the base table, do not support ad-hoc queries and usage requires knowledge of data access patterns in advance. GSIs can also not index any element below the top level record structure – so you cannot index nested fields, sub-documents or arrays.

Consistency

MongoDB is strongly consistent by default, as all reads and writes go to the primary in a MongoDB replica set, scaled across multiple partitions (shards). If desired, consistency requirements for read operations can be tuned. Through secondary consistency controls, read queries can be routed only to secondary replicas that fall within acceptable consistency limits with the primary server.

DynamoDB is eventually consistent by default. Users can configure read operations to return only strongly consistent data, but this doubles the cost of the read (see pricing and commercial considerations) and adds latency. There is also no way to guarantee read consistency when querying against DynamoDB’s global secondary indexes (GSIs); any operation performed against a GSI will be eventually consistent, returning potentially stale or deleted data and, therefore, increasing application complexity.

Transactions

MongoDB supports multi-document ACID transactions, making it the only database to combine the ACID guarantees of traditional relational databases; the speed, flexibility, and power of the document model; and the intelligent distributed systems design to scale out and place data where you need it.

Learn more on our MongoDB transactions page.

DynamoDB only supports single-region, multi-record ACID transactions for base tables. Unlike MongoDB transactions, each DynamoDB transaction is limited to just 100 write operations, and interactive transactions (read-before-write) are not supported. As a result, complex business logic may require multiple, independent transactions, which would add more code and overhead to the application, while also resulting in the possibility of more conflicts and transaction failures.

Operational Maturity

MongoDB Atlas allows users to deploy, manage, and scale their MongoDB clusters using built-in operational and security best practices, such as end-to-end encryption, network isolation, role-based access control (RBAC), VPC peering, and more. Atlas deployments are guaranteed to be available and durable with distributed and auto-healing replica set members and continuous backups with point-in-time recovery to protect against data corruption. MongoDB Atlas is fully elastic, with zero downtime configuration changes, and auto-scaling both storage and compute capacity. Atlas also grants organizations deep insights into how their databases are performing with a comprehensive monitoring dashboard, a real-time performance panel, and customizable alerting.

For organizations that would prefer to run MongoDB on their own infrastructure, MongoDB, Inc. offers advanced operational tooling to handle the automation of the entire database lifecycle, comprehensive monitoring (tracking 100+ metrics that could impact performance), and continuous backup. Product packages like MongoDB Enterprise Advanced bundle operational tooling and visualization and performance optimization platforms with end-to-end security controls for applications managing sensitive data.

MongoDB’s deployment flexibility allows single clusters to span racks, data centers, and continents. With replica sets supporting up to 50 members and geography-aware sharding across regions, administrators can provision clusters that support global deployments, with write local-read global access patterns and data locality. Using Atlas Global Clusters, developers can deploy fully managed “write anywhere” active-active clusters, allowing data to be localized to any region. With each region acting as primary for its own data, customers can meet the data sovereignty demands of new privacy regulations. Finally, multi-cloud clusters enable users to provision clusters that span across AWS, Azure, and Google Cloud, giving maximum resilience and flexibility in terms of data distribution.

Offered only as a managed service on AWS, DynamoDB abstracts away its underlying partitioning and replication schemes. While provisioning is simple, other key operational tasks are lacking when compared to MongoDB:

  • 35 database metrics are reported by AWS Cloudwatch, which limits visibility into real-time database behavior
  • DynamoDB has limited tooling to allow developers or DBAs to optimize performance by visualizing schema or graphically profiling query performance
  • DynamoDB supports cross-region replication with multi-primary global tables, however these add further application complexity and cost, risks of data loss due to write conflicts between regions, no data sovereignty controls and no automatic client failover

Pricing and Commercial Considerations

Pricing for MongoDB Atlas is relatively straightforward by selecting just:

  • The instance size with enough RAM to accommodate the portion of your data (including indexes) that clients access most often.
  • The number of replicas and shards that will make up the cluster.
  • Whether to include fully managed backups.
  • The region(s) the cluster needs to run in.

Users can adjust any of these parameters on demand. The only additional charge would be for data transfer costs.

In contrast, DynamoDB's pricing model is based on throughput. Users pay for a specific capacity on a given table, and AWS automatically throttles any reads or writes that exceed that capacity.

This sounds simple in theory, but correctly provisioning throughput and estimating pricing is far more nuanced. There are more than 15 factors that could impact the cost of running DynamoDB. To highlight a few, the number of indexes and multi-region replication multiply throughput cost, and single-region strongly consistent reads are twice as expensive as eventually consistent ones.

When to use DynamoDB vs. MongoDB

DynamoDB may work for organizations that are:

  • Looking for a database to support relatively simple key-value workloads.
  • Heavily invested in AWS with no plans to change their deployment environment in the future.

For organizations that need their database to support a wider range of use cases with more deployment flexibility and no platform lock-in, MongoDB would likely be a better fit.

For example, biotechnology giant Thermo Fisher migrated from DynamoDB to MongoDB for its Instrument Connect IoT app, saying that while both databases were easy to deploy, MongoDB Atlas allowed for richer queries and much simpler schema evolution.

Get started with Atlas today

Get started in seconds. Our free clusters come with 512 MB of storage so you can play around with sample data and get oriented with our platform.
Try FreeContact sales
GET STARTED WITH:
  • 125+ regions worldwide
  • Sample data sets
  • Always-on authentication
  • End-to-end encryption
  • Command line tools