Tuần 6 - Ngày 3: DynamoDB Deep Dive
1. DynamoDB Capacity Modes
2. Secondary Indexes
3. DynamoDB Accelerator (DAX)
4. DynamoDB Transactions
TransactWriteItems:
- Up to 100 items
- Atomic (all or nothing)
- Consumes 2x WCU
TransactGetItems:
- Up to 100 items
- Consumes 2x RCU
Use cases:
- Financial transactions
- Gaming leaderboards
- Multi-item updates
5. Time To Live (TTL)
Auto-delete expired items:
- No extra cost
- Eventually deleted (within 48 hours)
- Define TTL attribute (epoch timestamp)
Use cases:
- Session data
- Temporary tokens
- Log cleanup
6. Patterns
Single Table Design
PK | SK | Data
------------+-----------------+--------
USER#123 | METADATA | {name, email}
USER#123 | ORDER#001 | {order details}
USER#123 | ORDER#002 | {order details}
PRODUCT#A | METADATA | {product info}
ORDER#001 | PRODUCT#A | {line item}
Benefits:
- Single query for all user data
- Reduced latency
- Cost optimization
Tài liệu tham khảo chính thức
- Amazon DynamoDB Developer Guide
- DynamoDB Best Practices
- DynamoDB Global Tables
- DynamoDB Accelerator (DAX)
Ngày tiếp theo: Data Analytics Services