Arkinu
AWS service comparison

Amazon DocumentDB vs Amazon DynamoDB: differences and when to use each

Amazon DocumentDB
Amazon DynamoDB

Often confused on the examQuestions tend to offer one as a distractor for the other: look for the phrase in the scenario that tips the balance.

Database

Amazon DocumentDB

Fully managed document database compatible with MongoDB: you can use the same application code, drivers, and tools as with MongoDB. It handles operating and scaling MongoDB workloads in the cloud.

Exam phrases that point here

  • «managed document database that is compatible with MongoDB»

    Amazon DocumentDB is compatible with the MongoDB API: existing applications use the same drivers and tools, and AWS handles operations: automated backups, health monitoring, and failure recovery.

    When not: Not all MongoDB APIs are supported, so you should verify compatibility. If the scenario does not mention MongoDB and asks for key-based access at any scale with no servers, Amazon DynamoDB is usually a better fit.

  • «migrate an existing MongoDB database with minimal downtime»

    AWS DMS can move a self-managed MongoDB database (on premises or on EC2) to DocumentDB with practically no downtime.

    When not: If the source database is relational (for example, Oracle or MySQL), the logical target is Amazon RDS or Aurora, even though the migration tool is still AWS DMS.

  • «JSON documents with a flexible schema and ad hoc queries, indexes, and aggregations»

    A document model stores data whose structure changes (catalogs, user profiles, content) and lets you query it by any field with indexes and aggregations.

    When not: DocumentDB has its own text indexes, but with limits (English only, one text index per collection); if text search is the focus of the scenario, think of Amazon OpenSearch Service, a search and analytics engine. If access is always by key and you want a serverless millisecond-latency service, DynamoDB.

  • «low-latency reads in other Regions and recovery from the failure of a Region»

    Global clusters replicate the cluster from a primary Region to read-only secondary Regions, normally in under a second, and a secondary can be promoted if the primary fails.

    When not: In a global cluster only the primary Region accepts writes. If the scenario asks to write in several Regions at once (active-active), it points to DynamoDB global tables.

  • «scale writes horizontally with sharding»

    Elastic Clusters distributes data across shards by hash and lets you increase or decrease shards without changing the application, with little or no downtime.

    When not: If only reads need to scale, adding replicas to a regular cluster is enough. An existing cluster is not converted to an Elastic Cluster: you must migrate the data with AWS DMS.

Study Amazon DocumentDB →

Database

Amazon DynamoDB

Serverless, fully managed NoSQL database with key-value and document data models, delivering single-digit millisecond performance at any scale. It handles operational workloads that need consistent performance without managing servers or the complexity of scaling a relational database.

Exam phrases that point here

  • «single-digit millisecond latency at any scale»

    DynamoDB is a serverless NoSQL key-value and document database, designed to respond in single-digit milliseconds even as traffic and data grow.

    When not: If the scenario requires joins between tables, complex SQL queries, or referential integrity, it points to a relational database such as Amazon RDS or Amazon Aurora. And if it asks for microseconds, the clue is DAX in front of DynamoDB.

  • «unpredictable traffic and you do not want to plan capacity»

    On-demand capacity mode charges per request and adjusts to traffic on its own, without having to estimate reads and writes per second.

    When not: If traffic is steady and can be forecast, provisioned mode fits (normally with auto scaling), which gives more predictable costs. And if the application needs SQL, a serverless relational option such as Amazon Aurora Serverless is a better fit.

  • «microsecond response times for reads on a DynamoDB table»

    DynamoDB Accelerator (DAX) is an in-memory cache compatible with the DynamoDB API: it brings reads down from milliseconds to microseconds with minimal changes to the application.

    When not: DAX is not suitable if the application needs strongly consistent reads, nor is it a good fit for write-heavy workloads. If the source database is relational, the cache to think of is Amazon ElastiCache.

  • «run code automatically every time an item in the table changes»

    DynamoDB Streams records every insert, update, or delete in order, and an AWS Lambda function can be triggered with those records.

    When not: The stream keeps changes for only 24 hours. If you need longer retention, more consumers, or integration with other streaming tools, Kinesis Data Streams for DynamoDB fits. If events come from many different services, think of Amazon EventBridge.

  • «local reads and writes in multiple Regions, active-active»

    Global tables replicate the table in the Regions you choose and all of them accept reads and writes; there is no primary Region.

    When not: If the database is relational, the answer is usually Amazon Aurora Global Database, which writes in a primary Region. If the application uses Cassandra, Amazon Keyspaces offers multi-Region replication.

  • «automatically delete expired items without consuming write capacity»

    Time to Live (TTL) deletes each item when the timestamp it stores expires, without using write capacity. It is useful for sessions, temporary data, or records that lose value.

    When not: If the goal is to keep sessions in memory with sub-millisecond latency, Amazon ElastiCache also fits. If you are dealing with objects in S3, age-based deletion is done with S3 lifecycle rules, not TTL.

Often paired with

  • AWS Lambda
Study Amazon DynamoDB →