AWS · Database
Amazon DynamoDB
A fully managed key-value and document database that delivers single-digit-millisecond reads and writes at almost any scale.
What it is and what problem it solves
Amazon DynamoDB is a NoSQL database you do not provision servers for. Data lives in tables of items (like rows), found by a primary key: a partition key, optionally with a sort key. DynamoDB spreads items across partitions by the partition key, which is what lets it keep fast, predictable performance as a table grows.
You model data around the questions you will ask, not around relationships: queries use the key, and secondary indexes (global and local) support other access patterns. Reads are eventually consistent by default, with strongly consistent reads available, and transactions and global tables (multi-Region, multi-writer) are built in.
When to use it
- Access patterns are known and based on keys: look up a user, an order, a device, a session.
- You need consistent low latency at any scale, including huge or unpredictable traffic.
- You want no server management, with capacity that follows load (on-demand) or is set ahead (provisioned).
- You want data replicated across Regions with global tables, or automatic item expiry with TTL.
- A serverless application (Lambda, API Gateway) needs a database that scales the same way.
When to avoid it
- Ad hoc queries, joins and analytics across many attributes: use a relational database, or export to S3 and query with Athena.
- Items larger than the item size limit, or large binary objects: store those in S3 and keep a pointer in the item.
- Access patterns you do not know yet and that change often: modelling for DynamoDB is expensive to redo.
- Heavy relational integrity and complex transactions across many tables: a relational engine fits better.
Scaling model and bottlenecks
On-demand tables scale with traffic up to account and table quotas; provisioned tables scale to the capacity you set (with auto scaling to adjust it). The bottleneck to design against is the hot partition: if many requests hit one partition key value, that partition throttles even when the table as a whole has spare capacity. Choose a partition key with many distinct values that spreads requests evenly.
Performance, latency and throughput
Reads and writes at the key are fast and predictable. DAX, a managed in-memory cache, cuts read latency to microseconds for read-heavy, repeated lookups. Avoid scans on large tables, because a scan reads every item; use queries on keys and indexes instead.
Limits and quotas
Item size, key sizes, and the number of items in a batch or transaction are fixed limits that shape the data model. Table and throughput quotas can be raised.
| Item | Value | Context | Source |
|---|---|---|---|
| Maximum item size | 400 KB Fixed limit |
Includes attribute names and values. | Source checked |
| Partition key value size | 2,048 bytes maximum | Source checked |
|
| Sort key value size | 1,024 bytes maximum | Source checked |
|
| BatchWriteItem | 25 put or delete requests per call, 16 MB total | Source checked |
|
| BatchGetItem | 100 items per call, 16 MB total | Source checked |
|
| Items in a transaction | 100 unique items, 4 MB total | Source checked |
|
| Item collection size for a table with a local secondary index | 10 GB | Source checked |
|
| Tables per Region per account | 2,500 Can be raised with a quota request |
The initial quota; the page says it can be increased up to 10,000 through your AWS account team. | Source checked |
| Per-table throughput, on-demand | 40,000 read request units and 40,000 write request units Can be raised with a quota request |
Source checked |
Quotas and limits change. Check the linked source before designing around a number.
Cost model
What you pay for
- Capacity mode. On-demand: you pay per read request unit and write request unit. Provisioned: you pay per read and write capacity unit per hour, whether used or not, and can reserve capacity for a one- or three-year term.
- Storage of table data, in a Standard or Standard-Infrequent Access table class.
- Features: global table replication (replicated writes plus storage in every replica), backups and point-in-time recovery, restores, Streams reads, exports and imports, and DAX nodes.
- Data transfer: inbound is free; cross-Region and internet outbound are billed.
Where it is cost-efficient
On-demand mode for new, spiky or unpredictable workloads. Provisioned mode with auto scaling or reserved capacity for steady, predictable traffic. The Standard-IA table class for large tables read rarely.
Where costs grow
- Scans of large tables, which read (and bill for) every item.
- Strongly consistent and transactional reads and writes, which consume more units than eventually consistent ones.
- Large items, because units are charged per KB written or read.
- Global tables, since every write is replicated and billed in each replica Region.
- Provisioned capacity left far above real use.
Cost controls and common surprises
Model for key-based access, keep items small, use projections and filters that reduce read size, switch capacity mode as the workload matures, use TTL to expire data you do not need, and review the Consumed capacity metrics.
Prices differ by Region and change over time; see the pricing page linked under Sources.
Security
Controls the service provides
- Encryption at rest for all tables (AWS-owned key by default, or an AWS managed or customer managed KMS key), and encryption in transit.
- IAM controls access, down to individual items and attributes with fine-grained access control conditions.
- VPC gateway endpoints keep traffic private to DynamoDB.
What you configure
Give applications only the actions and tables they need, use fine-grained conditions to restrict users to their own items, use a gateway endpoint from private subnets, and choose a customer managed KMS key if you must control and audit key use.
Logging and monitoring
CloudTrail records control-plane and (optionally) data-plane events; CloudWatch metrics show throttles and consumed capacity; DynamoDB Streams can drive audit pipelines.
Related security services
IAM, KMS, VPC endpoints, CloudTrail and AWS Backup.
Shared responsibility
AWS secures the service and its infrastructure. You control access policies, key choices, data modelling and the data you store.
Availability, backup and failure behavior
DynamoDB stores data across multiple Availability Zones automatically. Point-in-time recovery restores a table to any second in the retention window, and on-demand backups and AWS Backup add scheduled copies. Global tables replicate to other Regions for low-latency local access and for Regional failover. Writes to a global table use last-writer-wins conflict resolution, so design for that.
Common service combinations
Lambda and API Gateway (serverless APIs), SQS and Step Functions (workflow state and idempotency records), DAX (read cache), Streams to Lambda (react to changes), S3 (large objects and exports), Athena for analytics on exports, and Cognito for per-user access.
Business application examples
- A shopping cart or session store keyed by user ID.
- Order records looked up by order ID, with an index on customer ID.
- Device telemetry written at a steady high rate and expired with TTL.
- An idempotency table that stops a payment from being processed twice.
Exam cues and common confusions
- Single-digit-millisecond at any scale, serverless, key-value: DynamoDB.
- Read-heavy, microsecond latency: DAX in front of DynamoDB.
- Multi-Region, multi-writer: global tables.
- Automatic expiry of items: TTL.
- Throttling with spare capacity overall: a hot partition key.
- Joins, complex SQL, ad hoc analytics: not DynamoDB; use Aurora/RDS, or Athena on exported data.
- Strong consistency: a strongly consistent read, which is not available on global secondary indexes.
Related
Courses and lessons
- Amazon DynamoDB · AWS Solutions Architect – Associate (SAA-C03) · Members
- Purpose-built databases: DocumentDB, Keyspaces, Neptune, Redshift and more · AWS Solutions Architect – Associate (SAA-C03) · Members
Services, comparisons and patterns
- AWS Lambda · Service
- Amazon API Gateway · Service
- Amazon ElastiCache · Service
- Amazon RDS · Service
- Amazon Aurora · Service
- Event-driven order processing · Solution pattern
- Disaster recovery strategies: backup and restore vs pilot light vs warm standby vs multi-site · Comparison
- RDS vs Aurora vs DynamoDB · Comparison
Sources
Independent study material, not affiliated with or endorsed by Amazon Web Services. AWS and service names are trademarks of Amazon.com, Inc. or its affiliates.