Overview
Amazon DynamoDB is a fully managed, serverless, NoSQL key-value and document database designed to provide single-digit millisecond performance at any scale. It handles administrative burdens like hardware provisioning, setup, configuration, and replication.
The Analogy: The Digital File Cabinet
Imagine a Relational Database (RDS) as a massive, interconnected library where every book must follow a strict Dewey Decimal System; if you want to find a specific page, you might have to check multiple cross-referenced indexes (Joins).
DynamoDB is like a high-speed Digital File Cabinet. Each drawer (Table) contains folders (Items). You don’t care how many folders are in the cabinet—whether it’s ten or ten billion—if you have the specific label (Partition Key), you can pull that folder out instantly. It’s built for speed and massive volume, not for complex cross-referencing.
Core Concepts & Well-Architected Lens
- Performance Efficiency: Uses SSD storage and automatic partitioning to maintain consistent latency even as data grows to petabytes.
- Reliability: Data is automatically replicated across three Availability Zones (AZs) within a region.
- Cost Optimization: Choose between On-Demand (pay-per-request) for unpredictable workloads or Provisioned Capacity (WCU/RCU) for stable traffic.
Service Comparison: SQL vs. NoSQL (DynamoDB)
| Feature | Amazon RDS (SQL) | Amazon DynamoDB (NoSQL) |
|---|---|---|
| Schema | Rigid / Fixed Columns | Flexible / Schema-less |
| Scaling | Vertical (Larger Instance) | Horizontal (More Partitions) |
| Joins | Complex Joins Supported | No Joins (De-normalize data) |
| Latency | Variable (depends on query) | Consistent (Single-digit ms) |
Scenario-Based Decision Matrix
If the requirement is… → Use this DynamoDB Feature:
- Extreme read performance for “hot” keys → DynamoDB Accelerator (DAX)
- Multi-region, multi-active disaster recovery → Global Tables
- Reacting to data changes in real-time (e.g., trigger Lambda) → DynamoDB Streams
- Automatically deleting old session data or logs → Time to Live (TTL)
- Ensuring multiple operations succeed or fail together → DynamoDB Transactions
Exam Tips: Golden Nuggets
- Scan vs. Query: A
Queryfinds items based on primary keys and is efficient. AScanlooks at every item in the table and is expensive/slow. Always prefer Query. - Local vs. Global Secondary Indexes: LSIs must be created at table creation and share the Partition Key. GSIs can be created anytime and can have a completely different Partition Key.
- Consistency: DynamoDB defaults to Eventually Consistent Reads. You must specifically request Strongly Consistent Reads (which cost double the RCU).
- Large Objects: DynamoDB has a 400KB item limit. For larger files, store the file in S3 and save the S3 URL in DynamoDB.
Architectural Flow
Key Services
- DAX: In-memory cache.
- Global Tables: Multi-region replication.
- KMS: Encryption at rest.
Common Pitfalls
- Hot Keys: Too many requests to one Partition Key.
- Large Items: Exceeding 400KB limit.
- Unbounded Scans: Consuming all RCU.
Quick Patterns
- Session Store: High speed, TTL for expiry.
- Leaderboards: Fast atomic increments.
- Metadata Store: For S3 objects.