🌈 DynamoDB
Amazon DynamoDB is a fully managed, serverless NoSQL database by AWS designed for high performance, extreme scalability, and low-latency workloads.
Think of DynamoDB as a super-fast digital filing cabinet that automatically grows, splits, balances, and manages itself — no servers, no storage ops, no maintenance.
You NEVER manage:
🔧 servers
📈 capacity scaling
🛠️ upgrades
🔁 replication
AWS handles everything behind the scenes.
⚡ Millisecond response time
⚡ Built for real-time applications
⚡ Can handle millions of requests per second
Used by: Netflix, Snapchat, AirBnB, Amazon.
DynamoDB is NOT relational.
It does not use SQL joins, foreign keys, or complex queries.
Instead, it uses:
Tables
Items (rows)
Attributes (columns)
A collection of data — similar to a sheet in Excel.
A single record (like a row).
Data fields (like columns).
A unique identifier for each item.
DynamoDB hashes the PK to decide the storage location.
Example:
UserID = 12345
Used with PK for composite key tables.
Allows multiple rows with same PK but different SK.
Example:
PK: UserID = 12345
SK: OrderID = 5678
Useful for:
Ordering
Filtering
Storing hierarchical data
Same PK as the table
Different sort key
Up to 5 LSIs
Used for: Alternative sorting.
Different PK & SK
Acts like a new view of your data
Very powerful
Used for: Flexible Querying.
You PAY only when you access data
Good for unpredictable traffic
Auto-scales instantly
Use when:
Traffic is spiky or unknown.
You define:
Read Capacity Units (RCU)
Write Capacity Units (WCU)
Use when:
You know your traffic patterns.
DynamoDB supports:
🔍 Query → Fast, uses PK/SK
🔎 Scan → Slow, reads full table
✏️ PutItem
📖 GetItem
🧽 DeleteItem
🛠️ UpdateItem
AWS KMS handles key management automatically.
Control who can read/write tables.
Secure access inside private networks.
Global tables replicate your data across multiple regions:
Benefits:
🌐 Low-latency worldwide
🔁 Automatic replication
💥 Disaster recovery built-in
🔄 Multi-master writes
Perfect for apps like:
Messaging apps
Multiplayer games
E-commerce carts
Streams capture every data change in real time.
Use cases:
🚨 Audit logs
🔄 Replication
⚡ Trigger AWS Lambda
📊 Analytics pipelines
You pay for:
🟢 Reads
🔵 Writes
🟣 Storage
🟡 Streams
🔴 Backups
🟠 Global tables
No hidden charges.
Perfect for:
Real-time apps
IoT
Gaming
E-commerce
Chat apps
Serverless backends
High-volume API workloads
Avoid when you need:
❌ Complex SQL joins
❌ Multi-row transactions
❌ Long analytical queries
❌ Heavy ad-hoc querying
Use RDS or Redshift instead.
Table Name: Orders
| Partition Key (PK) | Sort Key (SK) | Amount | Status |
|---|---|---|---|
| User#101 | Order#3001 | ₹1500 | Shipped |
| User#101 | Order#3002 | ₹700 | Pending |
| User#102 | Order#5001 | ₹2500 | Delivered |
🚀 Fastest NoSQL DB on AWS
🔧 No server management
🌍 Multi-region & durable
🔥 Handles millions of requests/sec
🧭 Key-based design is crucial
🤖 Integrates with Lambda, S3, API Gateway