Tables & Keys
- Partition key (hash key) is mandatory. Sort key (range key) is optional.
- Composite key = partition key + sort key. Enables range queries within a partition.
- Item size limit: 400 KB per item.
- Strongly consistent reads: latest data. Eventually consistent reads: may be stale, half the cost.
Secondary Indexes
- GSI (Global Secondary Index): different partition key + optional sort key. Eventually consistent only.
- LSI (Local Secondary Index): same partition key, different sort key. Must be created at table creation.
- GSIs have their own provisioned throughput; LSIs share the table's throughput.
- Max 20 GSIs and 5 LSIs per table.
Capacity Modes
- On-demand: pay per request. Auto-scales instantly. Good for unpredictable workloads.
- Provisioned: set RCUs and WCUs. Use Auto Scaling for dynamic adjustment.
- 1 RCU = 1 strongly consistent read/s for items ≤ 4 KB (or 2 eventually consistent reads).
- 1 WCU = 1 write/s for items ≤ 1 KB.
DynamoDB Streams & Transactions
- Streams capture item-level changes (INSERT, MODIFY, REMOVE) in near real-time.
- Stream records have a 24-hour lifetime. Lambda can process stream records via event source mapping.
- Transactions: TransactWriteItems and TransactGetItems support ACID across up to 100 items / 4 MB.
- Transactions consume 2x the WCUs/RCUs of normal operations.
DAX & Caching
- DAX is a DynamoDB-specific in-memory cache — microsecond read latency.
- DAX is a write-through cache; writes go to DynamoDB first, then update the cache.
- Use ElastiCache when you need caching for non-DynamoDB data or complex caching logic.
- TTL automatically deletes expired items without consuming WCUs (background process).
Practice DynamoDB Questions
Put your knowledge to the test with practice questions.