Introduction to Amazon DynamoDB
Amazon DynamoDB is a fully managed, serverless NoSQL database service from AWS.
Introduction
Amazon DynamoDB is a fully managed, serverless NoSQL database service from AWS. It is designed for applications that need predictable low latency, automatic scaling, and high availability without database server administration.
Imagine you are building a global e-commerce platform. Millions of users browse products, search inventory, add items to carts, place orders, and generate transactions every hour. Every click creates data. If all of that traffic goes to one traditional database server, performance eventually degrades during traffic spikes.
Amazon faced this same challenge at massive scale. The internal Dynamo distributed database influenced the design of Amazon DynamoDB, a managed database service built for internet-scale workloads.
Purpose of this lesson
By the end of this lesson, you will understand what DynamoDB is, why AWS created it, how it differs from SQL databases, where it fits in cloud architecture, and when it is the right database choice for production systems.
Understanding the topic
DynamoDB uses a key-value and document data model. Instead of designing many normalized tables and joining them at query time, you model data around the exact access patterns your application needs.
- Fully managed: AWS handles servers, storage, replication, backups, patching, and scaling.
- Serverless: you do not provision or manage database machines.
- Low latency: common read and write operations are designed for single-digit millisecond response times.
- Horizontal scale: DynamoDB partitions data across storage nodes automatically.
- AWS native: integrates with Lambda, IAM, CloudWatch, API Gateway, EventBridge, and Global Tables.
For example, one customer item may contain only CustomerId, Name, and Email, while another may also contain Membership and RewardPoints. DynamoDB does not require every item in a table to share the exact same attributes.
| SQL Database | DynamoDB NoSQL |
|---|---|
| Fixed schema | Flexible item attributes |
| Relationships and joins | Key-value and document access |
| Primarily vertical scaling plus replicas/shards | Automatic horizontal partitioning |
| Great for relational transactions and reporting | Great for high-throughput application access patterns |
Internal architecture
At a high level, an application calls DynamoDB through AWS APIs. DynamoDB uses the partition key to route the request to the right storage partition, then replicates data across multiple Availability Zones for durability and availability.
Internal Architecture
DynamoDB Request Routing and Storage
Step-by-step explanation
- The application sends a read or write request to DynamoDB.
- DynamoDB uses the partition key to determine where the item belongs.
- The request is routed directly to the correct storage partition.
- The item is read or written.
- Changes are replicated across multiple Availability Zones.
- A response is returned, usually within a few milliseconds for well-designed access patterns.
Real-world use
Real-world applications
- E-commerce: shopping carts, product catalogs, wish lists, customer sessions, and order status.
- Banking and fintech: session management, fraud signals, user preferences, transaction metadata, and audit-friendly event records.
- Gaming: player profiles, leaderboards, game progress, matchmaking, and real-time state.
- IoT: sensor telemetry, device state, event history, and high-volume device writes.
- Social media: user profiles, notifications, activity feeds, likes, reactions, and online presence.
Decision framework
- Choose DynamoDB when access patterns are known and mostly key-based.
- Choose DynamoDB when the system needs high throughput, low latency, and high availability with minimal operations work.
- Choose DynamoDB for serverless and event-driven architectures, especially with Lambda, API Gateway, EventBridge, and streams.
- Avoid DynamoDB when the core workload depends on complex joins, ad hoc SQL reporting, heavy analytical queries, or strict relational constraints across many tables.
- For relational systems with complex reporting, Amazon RDS or Amazon Aurora is often a better fit.
Best practices
- Design the data model around application access patterns before creating tables.
- Choose partition keys that distribute traffic evenly and avoid hot partitions.
- Use
Queryoperations whenever possible; avoid relying on full tableScanoperations. - Store only attributes the application needs for its access patterns.
- Monitor table metrics with Amazon CloudWatch.
- Use IAM least privilege for applications and operators.
- Enable encryption and plan backups for sensitive or business-critical data.
- Think about growth early: item size, write volume, partition key distribution, and future indexes.
Common mistakes
- Treating DynamoDB like a relational database.
- Designing tables before understanding access patterns.
- Choosing a partition key that concentrates traffic on one hot partition.
- Using
Scanfor every read path. - Ignoring read and write capacity behavior.
- Forgetting production monitoring and alarms.
- Adding unnecessary attributes that increase item size and cost.
Advanced interview questions
Interview Prep
Practice concise answers, then expand each card for the explanation.
1BeginnerQuestionWhat is Amazon DynamoDB?+
Answer
2BeginnerQuestionWhy was DynamoDB created?+
Answer
3IntermediateQuestionHow is DynamoDB different from a SQL database?+
Answer
4IntermediateQuestionWhen should you choose DynamoDB?+
Answer
5AdvancedQuestionWhat is a common production mistake in DynamoDB design?+
Answer
Hands-on exercise
Imagine you are designing an online food delivery platform. Identify five pieces of information you would store in DynamoDB and explain why DynamoDB is appropriate for each one.
- Customer sessions
- Restaurant menus
- Live order tracking
- Driver locations
- User notifications
Summary
DynamoDB is a managed NoSQL database built for applications that need scale, availability, and low-latency access without managing database infrastructure. The main engineering skill is not writing complex SQL; it is designing the table around real access patterns, choosing strong keys, and avoiding relational habits that do not fit DynamoDB.
Next: Lesson 2 will explain why NoSQL exists, how horizontal scaling changed database design, the major NoSQL database types, the CAP theorem, and how to decide between SQL and NoSQL in real systems.