What Is DynamoDB? AWS NoSQL Database Explained
DynamoDB is AWS’s managed NoSQL database built for applications that need fast, predictable responses at any scale. It handles millions of reads and writes per second with no servers to manage, no sharding to configure, and no capacity planning required in On-Demand mode.
Simple explanation
Think of DynamoDB like a filing cabinet with labelled drawers
Most databases let you search through everything and find what you need. DynamoDB works differently. You decide upfront exactly which drawer each piece of data lives in, and every lookup goes straight to that drawer.
The benefit: it is blindingly fast and scales automatically. The trade-off: if you need to search the entire cabinet for something without knowing which drawer to open, that is slow and expensive. DynamoDB rewards you for knowing your access patterns before you build.
DynamoDB is a strong choice for session storage, shopping carts, gaming leaderboards, IoT telemetry, and any workload that hits the same key-based lookups at very high speed. It is a poor fit for reporting, analytics, or applications with flexible and evolving query requirements.
How DynamoDB works
DynamoDB stores data in tables. Each table holds items (a single record), and each item has attributes (name-value pairs, similar to fields). Unlike a relational database, you do not define a schema for every attribute upfront. You only define the key attributes; the rest can vary per item.
Every item is identified by a primary key, which comes in two forms:
- Partition key only: A single attribute that uniquely identifies each item. Good when every lookup is by a single ID, such as
userIdin a users table. - Partition key + sort key: A composite key where items share a partition key but differ on the sort key. This stores related items together and lets you query them as a group or in order.
A concrete example: An e-commerce order history table might use userId as the partition key and orderId as the sort key. All orders for a given user live in the same partition. You can retrieve every order for a user in a single query, or narrow it down to orders placed after a certain date using the sort key.
This design makes DynamoDB fast. It also means your access patterns need to be decided before you design your table. If a query your application needs cannot be answered with a key lookup or index, you are left doing a full table scan, which is slow and expensive. For a deep look at data modelling, see the DynamoDB Data Model guide.
What DynamoDB is good at
High throughput. DynamoDB handles millions of reads and writes per second. Storage and throughput scale independently, horizontally, and automatically. You do not manage sharding, replication, or failover.
Predictable low latency. Responses return in single-digit milliseconds at any scale. This consistency comes from the design constraint: queries are always by primary key or index, never ad hoc table scans.
Flexible item structure. Each item can have a different set of attributes. You only define the key attributes upfront. This works well for heterogeneous objects where not every record shares the same fields, such as a product catalogue where clothing has size and colour but electronics have wattage and voltage.
Global replication. DynamoDB Global Tables replicate data across multiple AWS regions with active-active writes. Users in different regions can read and write to the same logical table with low latency.
When to use DynamoDB
DynamoDB fits workloads where:
- Access patterns are known and predictable. You know exactly how your application will look up data before you build the schema.
- Throughput and scale matter more than query flexibility. You need consistent performance at high request volume.
- Low operational overhead is a priority. No database servers to patch, size, or manage.
Specific workloads where DynamoDB excels:
- User sessions: store and retrieve session state by session ID at high speed
- Shopping carts: read and update cart contents by user ID
- Gaming leaderboards: rank players by score using a Global Secondary Index
- IoT telemetry: write sensor readings at high frequency, retrieve by device ID and timestamp
- High-scale APIs with predictable access patterns: user profiles, feature flags, configuration stores
- Event-driven architectures: DynamoDB Streams can trigger AWS Lambda functions when items change, making it a natural fit for event-driven systems
When not to use DynamoDB
”It scales better” is not a reason to choose DynamoDB on its own. DynamoDB only scales well for the access patterns it was designed for. Choosing it for the wrong workload creates pain that compounds as your data grows.
Avoid DynamoDB when:
- You need ad hoc SQL queries. If your team needs to filter, group, or aggregate data in flexible ways, DynamoDB forces a full table scan or requires you to build those patterns into your schema ahead of time.
- Your data is relational with complex joins. Orders that join with customers, products, suppliers, and invoices belong in a relational database.
- Your schema has many-to-many relationships. These patterns require workarounds in DynamoDB that quickly become brittle.
- You are building reporting or analytics features. DynamoDB is not optimised for aggregations, GROUP BY, or exploratory queries. Export to S3 or use Amazon Redshift for analytics.
- Your query patterns are still unknown. Start with RDS if you are still working out how the application will access data. Migrating to DynamoDB later is easier than redesigning a DynamoDB schema in production.
Core concepts
DynamoDB uses different terminology from relational databases:
| DynamoDB term | Relational equivalent | Notes |
|---|---|---|
| Table | Table | Top-level container for data |
| Item | Row / record | A single data object; attributes can differ per item |
| Attribute | Column / field | A name-value pair; only key attributes are required |
| Partition key | Primary key | Required; determines which physical partition stores the item |
| Sort key | Composite key component | Optional; enables range queries within a partition |
| Global Secondary Index (GSI) | Index on non-primary key columns | Enables queries on non-key attributes; has its own partition and sort key |
| Local Secondary Index (LSI) | Alternate sort order | Same partition key, different sort key; must be defined at table creation |
Items can be up to 400 KB and contain nested maps, lists, and sets. This is much closer to a JSON document than a SQL row. For a full walkthrough of how to model data with these building blocks, see DynamoDB Data Model.
Partition key design
The partition key is the most consequential design decision in a DynamoDB table. DynamoDB uses it to distribute data across internal storage nodes. A good partition key spreads traffic evenly. A bad one creates hot partitions: one node receiving most of the reads and writes while the rest sit idle.
Using status (values: active, pending, closed) as a partition key is a common mistake. Most items are probably active, so that single partition gets hammered while the others see almost no traffic. You have effectively limited yourself to a fraction of the available throughput.
Use userId (a UUID or unique ID per user) as the partition key instead. Thousands or millions of distinct values spread traffic across many partitions. Each user’s operations hit a different partition, so load distributes evenly.
The rule: your partition key should have high cardinality (many distinct values) and traffic should distribute roughly evenly across those values. If you cannot find a natural high-cardinality attribute, consider appending a shard suffix to an existing one.
Capacity modes: On-Demand vs Provisioned
On-Demand mode handles any volume of traffic automatically. You pay per request (per read unit and write unit consumed) with no capacity to configure. Traffic can spike from zero to millions of requests per second without any pre-planning.
Best for: new applications with unknown traffic patterns, dev/test environments, and workloads with large spikes followed by quiet periods.
Provisioned mode with Auto Scaling lets you set a target read and write throughput in capacity units per second. Auto Scaling adjusts capacity within the bounds you define based on actual usage. This costs less per request than On-Demand at sustained high traffic.
Best for: stable, predictable workloads at scale where you want to control cost.
| Mode | Capacity management | Best for |
|---|---|---|
| On-Demand | None required; fully automatic | Variable traffic, new applications, unpredictable spikes |
| Provisioned | Set RCUs and WCUs, use Auto Scaling | Steady, predictable traffic at scale; cost optimisation |
Start with On-Demand mode while you learn your workload’s shape. Once traffic stabilises, compare actual request costs against Provisioned pricing to decide whether switching is worth it. You can change modes, but AWS limits how frequently you can switch.
Read consistency
DynamoDB offers two consistency options:
Eventually consistent reads are the default. Reads may not reflect the very latest write. In practice, consistency is reached within milliseconds, but there is a brief window where a read after a write might return the previous value. These reads cost half the capacity of strongly consistent reads.
Strongly consistent reads are guaranteed to return the most recent data. Use this when your application cannot tolerate stale reads, for example when reading back immediately after a write to confirm a value was stored. These reads consume twice the read capacity units.
Eventual consistency suits the vast majority of read operations. The cost difference is real; the performance difference is negligible for most applications. Only request strong consistency where your logic actually requires it.
Global Tables
DynamoDB Global Tables replicate your data across multiple AWS regions with active-active writes. Every region accepts reads and writes. Changes in one region propagate to all others, typically within one to two seconds.
Global Tables suit:
- Applications with users across multiple geographic regions who need low-latency local access
- Disaster recovery with a recovery point objective measured in seconds rather than hours
- Gaming, social media, or IoT workloads with a global footprint
Conflict resolution uses last-writer-wins based on timestamps. If the same item is written in two regions simultaneously, the write with the more recent timestamp wins.
DynamoDB vs RDS
RDS and DynamoDB are not competing products. They solve different problems. Choosing between them is a workload question, not a “which is better” question.
| Factor | DynamoDB | RDS (MySQL / PostgreSQL) |
|---|---|---|
| Schema | Flexible; only key attributes required | Fixed; all columns defined upfront |
| Query language | DynamoDB API (key-based lookups) | SQL (flexible ad hoc queries) |
| Joins | Not supported | Full SQL JOIN support |
| Scaling | Horizontal, automatic, to any size | Vertical (larger instance) or read replicas |
| Latency | Single-digit milliseconds consistently | Low, but can degrade under complex query load |
| Transactions | Supported within a single request (up to 100 items) | Full ACID transactions across any number of rows |
| Multi-region | Built-in with Global Tables | Manual cross-region setup required |
Choose DynamoDB if:
- Access patterns are known, key-based, and high-volume
- You need automatic horizontal scale without a ceiling
- You are building sessions, carts, leaderboards, or event-driven workloads
- Operational simplicity matters more than query flexibility
Choose RDS if:
- Your data is relational with natural joins between entities
- You need flexible SQL queries or ad hoc reporting
- Query patterns are still evolving and not fully known
- You need full ACID transactions across many rows
For a detailed side-by-side breakdown, see RDS vs DynamoDB.
Common mistakes
- Choosing DynamoDB without knowing the query model. DynamoDB only works well if your access patterns are key-based. If you are not sure yet how the application will query data, start with RDS. You can migrate later, but redesigning a DynamoDB table schema in production is painful.
- Choosing a low-cardinality partition key. A partition key with few distinct values (like a boolean or a status field with three options) concentrates writes to a small number of partitions. This creates hot partitions that choke throughput. Use high-cardinality identifiers like user IDs or UUIDs.
- Relying on scans instead of queries. A Scan operation reads every item in the table. It is slow, expensive, and does not scale. If your application is scanning frequently, the table schema needs rethinking. See DynamoDB Queries for how to structure operations correctly.
- Thinking in SQL tables instead of access patterns. The most common mistake when migrating from relational databases is modelling DynamoDB like a SQL schema with one table per entity. DynamoDB is designed around access patterns, not entity relationships. Often the right model is a single table that serves multiple query shapes.
- Picking On-Demand mode for all workloads without checking cost. On-Demand mode is convenient and right for variable or unknown traffic. At sustained high throughput, Provisioned mode with Auto Scaling costs less per request. Check actual usage before committing to a capacity mode.
- Skipping encryption and access controls. DynamoDB supports server-side encryption with AWS KMS and fine-grained access control via IAM. Review DynamoDB Security before putting sensitive data into production.
Summary
- DynamoDB is a managed NoSQL key-value and document store that scales automatically to any throughput level.
- Data is organised into tables made up of items with attributes; only key attributes need to be defined upfront.
- Primary keys are either partition key only (simple) or partition key plus sort key (composite, for range queries).
- Partition key design is critical: high cardinality prevents hot partitions and keeps throughput distributed evenly.
- On-Demand mode requires no capacity planning; Provisioned mode costs less for steady, predictable workloads.
- DynamoDB is right for key-based lookups at scale; RDS is right for relational data and flexible SQL queries.
- Global Tables provide active-active multi-region replication with seconds-level propagation.
Frequently asked questions
Is DynamoDB serverless?
In On-Demand mode, DynamoDB behaves like a serverless database. You pay per request with no capacity to configure. In Provisioned mode, you set throughput capacity in advance. There are no servers to manage in either mode.
What is the difference between a partition key and a sort key?
The partition key determines which physical partition stores the item. All items with the same partition key are stored together. The sort key orders items within a partition and enables range queries. You must always specify the partition key in queries; the sort key is optional and enables more targeted lookups.
When should I use DynamoDB instead of RDS?
Choose DynamoDB when your access patterns are predictable and key-based, your application needs to scale to very high throughput, and you do not need complex SQL queries or joins. Choose RDS when your schema is relational, you need flexible ad hoc queries, or you are building reporting or analytics features.
Does DynamoDB support joins?
No. DynamoDB does not support SQL-style joins. If your application needs to join data from multiple entities, you need to either model everything into a single table using access-pattern-driven design, or use a relational database like RDS.
Is DynamoDB good for analytics?
Not as a primary analytics store. DynamoDB is optimised for fast, key-based lookups, not for aggregations, groupings, or full table scans. For analytics workloads, consider exporting DynamoDB data to Amazon Redshift or S3, or use a purpose-built analytics service.