Amazon DynamoDB
Ultra-fast NoSQL key-value
A serverless NoSQL database with key-based queries at millisecond latency at any scale; pay per request or for capacity.
- Cost$ Low
- Difficulty●●●●●
- Costs money when idle?A little
- Serverless
- In examsCLF · SAA · DVA · SOA
Think of it asLike a numbered filing cabinet: know the number and you pull it out instantly, but you can't freely rummage around.
Where does DynamoDB fit?
Calls DynamoDB
DynamoDB calls
A real example, step by step
- A mobile game needs to store scores and profiles for a few million players, read and written all day long.
- You create a DynamoDB table with playerId as the key and choose on-demand mode, so you don't have to guess the traffic.
- Every time a player saves a score, the game writes an item; reading it back by playerId takes a few milliseconds no matter how many players there are.
- Per-level leaderboards use a global secondary index to query in a different way.
- DynamoDB Streams invokes Lambda on every new score to send “you've just been overtaken” notifications.
When to use it
✓ Use it when
Access patterns known in advance, need massive scale: shopping carts, sessions, IoT, games.
✗ Avoid it when
You need JOINs, ad-hoc queries, complex reporting → RDS/Aurora.
Common uses
- Shopping carts, sessions, user profiles
- Game leaderboards, IoT, ad-tech needing millisecond latency
- Serverless backends with Lambda
- Storing state, deduplication locks (idempotency)
DynamoDB, RDS or ElastiCache?
| Data model | Key-value / document | Relational tables (SQL) | In-memory cache |
|---|---|---|---|
| Scaling | Scales almost without limit | By instance size + replicas | By nodes or serverless |
| Queries | By key and indexes | Any SQL, with JOINs | By key |
| Durability | Durable, stored across AZs | Durable, with backups | For speed; not a replacement for a database |
What does it cost?
- Pricing model: On-demand: per read/write request (~$0.125/1 million read units, ~$0.625/1 million write units after the November 2024 price cut). Or Provisioned per RCU/WCU-hour. Storage ~$0.25/GB-month.
- Free tier: Always Free: 25 GB of storage + 25 WCU and 25 RCU (provisioned mode).
Scanning the whole table instead of using Query; each GSI adds write costs; large items consume many units; enabling Streams, PITR, Global Tables when not needed.
“Key-value”, “millisecond latency at any scale”, “serverless” → DynamoDB. Microsecond reads → DAX. Automatically delete expired data → TTL. Writes from several regions → global tables.
Try real exam questions
1An application running in a private subnet accesses an Amazon DynamoDB table. The data cannot leave the AWS network to meet security requirements. How should this requirement be met?
- AConfigure a network ACL on DynamoDB to limit traffic to the private subnet.
- BEnable DynamoDB encryption at rest using an AWS Key Management Service (AWS KMS) key.
- CAdd a NAT gateway and configure the route table on the private subnet.
- DCreate a gateway VPC endpoint for DynamoDB and configure the endpoint policy.
Show answer
Correct answer: D
A gateway VPC endpoint for DynamoDB keeps traffic on the AWS network, never over the internet. A NAT gateway still goes out to the internet; encryption at rest has nothing to do with the network path.
2A recently created startup built a three-tier web application. The front end has static content. The application layer is based on microservices. User data is stored as JSON documents that need to be accessed with low latency. The company expects regular traffic to be low during the first year, with peaks in traffic when it publicizes new features every month. The startup team needs to minimize operational overhead costs. What should a solutions architect recommend to accomplish this?
- AUse Amazon S3 static website hosting to store and serve the front end. Use AWS Elastic Beanstalk for the application layer. Use Amazon DynamoDB to store user data.
- BUse Amazon S3 static website hosting to store and serve the front end. Use Amazon Elastic Kubernetes Service (Amazon EKS) for the application layer. Use Amazon DynamoDB to store user data.
- CUse Amazon S3 static website hosting to store and serve the front end. Use Amazon API Gateway and AWS Lambda functions for the application layer. Use Amazon DynamoDB to store user data.
- DUse Amazon S3 static website hosting to store and serve the front end. Use Amazon API Gateway and AWS Lambda functions for the application layer. Use Amazon RDS with read replicas to store user data.
Show answer
Correct answer: C
S3 for the static front end, API Gateway + Lambda for processing, DynamoDB for JSON data: all serverless, pay per use and scaling automatically for the monthly peaks. EKS or Elastic Beanstalk still leave servers to operate.
Frequently asked questions
What is the difference between on-demand and provisioned capacity?
On-demand charges per read and write with no need to predict traffic, which suits unpredictable workloads. Provisioned reserves a number of reads and writes per second (optionally with auto scaling) and is cheaper when traffic is steady.
How should I design keys in DynamoDB?
Choose a partition key with many distinct, evenly spread values so traffic doesn't pile onto one partition. Use sort keys and secondary indexes (GSI, LSI) for different query patterns. List the queries you need before designing the table.
What do AWS exams ask about DynamoDB?
Choosing on-demand or provisioned, GSIs and LSIs, DAX for microsecond reads, DynamoDB Streams to trigger Lambda, TTL to expire old items, global tables for multiple regions, and strongly consistent versus eventually consistent reads.