Xoxoftware - XOXO Creative Studio | Web & Mobile App Development | Fred Cheung | Hong Kong
AWSDatabase

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:

ServiceData ModelCompatible WithBest For
Amazon DynamoDBKey-value + documentDynamoDB API (proprietary)High-scale, low-latency, serverless apps
Amazon DocumentDBDocument (JSON)MongoDB APIMongoDB 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

ConceptDescription
TableTop-level container for items (equivalent to a table/collection)
ItemA single record (equivalent to a row or document) — up to 400 KB
Partition KeyPrimary 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
AttributeA field within an item; schema-less (items in the same table can have different attributes)

Capacity Modes

ModeDescriptionBest For
On-DemandAuto-scales; pay per requestUnpredictable or spiky traffic
ProvisionedSet Read Capacity Units (RCUs) and Write Capacity Units (WCUs) manually or with auto-scalingPredictable, 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

ModelDescription
Eventually Consistent ReadsDefault; up to ~1 second lag after a write (cheaper — half the RCU cost)
Strongly Consistent ReadsReturns 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

DimensionDynamoDBDocumentDB
Data modelKey-value + documentDocument (JSON)
APIProprietary DynamoDB APIMongoDB-compatible
Query languagePartiQL (SQL-like) or DynamoDB APIMongoDB Query Language (MQL)
ScalingTruly serverless, automaticManual cluster scaling
Use whenGreenfield AWS-native apps, max scaleMigrating MongoDB workloads

Cross-Cloud Equivalents

DynamoDB

ProviderService / SolutionNotes
AWSAmazon DynamoDBBaseline
AzureAzure Cosmos DB (API: NoSQL)Multi-model; similar global distribution and consistency-level model
GCPBigtable / FirestoreBigtable for wide-column; Firestore for document model
On-PremisesApache Cassandra, ScyllaDBWide-column stores with similar partition-key design principles

DocumentDB

ProviderService / SolutionNotes
AWSAmazon DocumentDBBaseline
AzureAzure Cosmos DB (API: MongoDB)Also MongoDB-compatible; global distribution built-in
GCPFirestore / MongoDB Atlas on GCPFirestore is native; MongoDB Atlas available as managed service
On-PremisesMongoDB Community / EnterpriseDocumentDB 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

Built by Fred Cheung @CookedRicer · Powered by Fumadocs & Github Copilot

On this page