Amazon DynamoDB and DocumentDB
AWS managed NoSQL database services — Amazon DynamoDB (key-value / document) and Amazon DocumentDB (MongoDB-compatible). Covers data models, use cases, scaling, and cross-cloud equivalents.
Overview
Amazon DynamoDB and DocumentDB are AWS's managed NoSQL database services — DynamoDB for key-value and document workloads at any scale, and DocumentDB for teams migrating MongoDB applications to AWS.
AWS offers multiple managed NoSQL database services for non-relational workloads. The two primary options are:
| Service | Data Model | Compatible With | Best For |
|---|---|---|---|
| Amazon DynamoDB | Key-value + document | DynamoDB API (proprietary) | High-scale, low-latency, serverless apps |
| Amazon DocumentDB | Document (JSON) | MongoDB API | MongoDB workloads migrated to AWS |
Amazon DynamoDB
AWS's fully managed, serverless key-value and document database. Designed for single-digit millisecond latency at any scale.
Key Concepts
| Concept | Description |
|---|---|
| Table | Top-level container for items (equivalent to a table/collection) |
| Item | A single record (equivalent to a row or document) — up to 400 KB |
| Partition Key | Primary key attribute; DynamoDB uses it to distribute data across partitions |
| Sort Key (optional) | Combined with partition key to form a composite primary key; enables range queries |
| Attribute | A field within an item; schema-less (items in the same table can have different attributes) |
Capacity Modes
| Mode | Description | Best For |
|---|---|---|
| On-Demand | Auto-scales; pay per request | Unpredictable or spiky traffic |
| Provisioned | Set Read Capacity Units (RCUs) and Write Capacity Units (WCUs) manually or with auto-scaling | Predictable, steady workloads (lower cost) |
SAA/SAP Tip: For new or unknown workloads, start with On-Demand mode. Switch to Provisioned + Auto Scaling once patterns are established to reduce cost.
Key Features
- DynamoDB Streams — ordered log of item-level changes; triggers Lambda for event-driven (downstream processing) patterns
- Global Tables — multi-region, multi-active (Active/Active) replication; automatic conflict resolution
- DynamoDB Accelerator (DAX) — fully managed, in-memory cache for DynamoDB; reduces read latency from milliseconds to microseconds
- Point-in-Time Recovery (PITR) — continuous backups; restore to any second in the past 35 days
- TTL (Time to Live) — automatically expire and delete items after a set timestamp; no extra cost
Consistency Models
| Model | Description |
|---|---|
| Eventually Consistent Reads | Default; up to ~1 second lag after a write (cheaper — half the RCU cost) |
| Strongly Consistent Reads | Returns the latest data immediately after a write (costs 1 full RCU per read) |
| Transactions (ACID) | TransactWriteItems / TransactGetItems — atomic operations across up to 25 items |
Exam Trap: DynamoDB does not support complex SQL joins or multi-table relationships. If a scenario requires ad-hoc queries across relationships, a relational database (RDS / Aurora) is more appropriate.
SAA/SAP Tip: DynamoDB Global Tables enable a Multi-Site Active/Active Disaster Recovery (DR) pattern for serverless architectures. Pair with Route 53 latency-based routing for global low-latency access.
Common Use Cases
- Session management / user profiles
- Shopping cart / gaming leaderboards
- IoT device state and telemetry
- Real-time bidding, ad tech
- Event sourcing with DynamoDB Streams → Lambda
Amazon DocumentDB
AWS's managed document database service with MongoDB API compatibility. Designed as a drop-in replacement for MongoDB workloads migrating to AWS.
Important: DocumentDB is MongoDB-compatible, not MongoDB itself. There are version and feature gaps. Always validate API compatibility before migration.
Key Properties
- Stores data as JSON documents (flexible schema)
- Compatible with MongoDB 3.6, 4.0, and 5.0 drivers and tools
- Storage automatically grows in 10 GiB increments up to 64 TiB
- Replication: up to 15 read replicas across up to 3 AZs
- Automatic backups with point-in-time restore
Use Cases
- Content management systems (CMS)
- User profile and catalog data with nested/hierarchical structure
- Migrating existing MongoDB workloads to AWS without rewriting application code
DynamoDB vs. DocumentDB
| Dimension | DynamoDB | DocumentDB |
|---|---|---|
| Data model | Key-value + document | Document (JSON) |
| API | Proprietary DynamoDB API | MongoDB-compatible |
| Query language | PartiQL (SQL-like) or DynamoDB API | MongoDB Query Language (MQL) |
| Scaling | Truly serverless, automatic | Manual cluster scaling |
| Use when | Greenfield AWS-native apps, max scale | Migrating MongoDB workloads |
Cross-Cloud Equivalents
DynamoDB
| Provider | Service / Solution | Notes |
|---|---|---|
| AWS | Amazon DynamoDB | Baseline |
| Azure | Azure Cosmos DB (API: NoSQL) | Multi-model; similar global distribution and consistency-level model |
| GCP | Bigtable / Firestore | Bigtable for wide-column; Firestore for document model |
| On-Premises | Apache Cassandra, ScyllaDB | Wide-column stores with similar partition-key design principles |
DocumentDB
| Provider | Service / Solution | Notes |
|---|---|---|
| AWS | Amazon DocumentDB | Baseline |
| Azure | Azure Cosmos DB (API: MongoDB) | Also MongoDB-compatible; global distribution built-in |
| GCP | Firestore / MongoDB Atlas on GCP | Firestore is native; MongoDB Atlas available as managed service |
| On-Premises | MongoDB Community / Enterprise | DocumentDB is designed as AWS's managed replacement |
Pricing Model
DynamoDB:
- On-Demand: per million read/write request units
- Provisioned: per RCU/WCU per hour
- Storage per GB-month; DAX, Streams, and Global Tables incur additional charges
DocumentDB:
- Per instance-hour (cluster instances)
- Per GB-month for storage and I/O
- Data transfer charges apply for cross-region replication
Related Services / See Also
- Amazon RDS & Aurora — managed relational (SQL) databases
- Database Performance Fundamentals — OLTP/OLAP, IOPS concepts
- Amazon ElastiCache — Redis/Memcached in-memory cache layer
- Amazon Keyspaces — managed Apache Cassandra-compatible service
Amazon ElastiCache
Amazon ElastiCache — managed in-memory caching with Redis and Memcached. Covers caching patterns, Redis data structures, cluster modes, and cross-cloud equivalents.
Amazon RDS and Aurora
Amazon Relational Database Service (RDS) and Amazon Aurora — managed relational databases on AWS. Covers deployment options, Multi-AZ HA, Read Replicas, Aurora architecture, and cross-cloud equivalents.