By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Hyper-practical, zero-fluff guide for real projects & AWS SAA exam
You’re a cloud engineer at a fast-growing SaaS company. Your team just migrated a monolithic app to microservices, and the legacy MySQL database is now a bottleneck—latency spikes during peak hours, and scaling reads is a nightmare. Your CTO asks: "Can we replace this with something serverless, auto-scaling, and globally distributed?"
DynamoDB is the answer. It’s AWS’s fully managed NoSQL database that scales to millions of requests per second with single-digit millisecond latency. But here’s the catch: - If you misconfigure RCUs/WCUs, your app will throttle under load (HTTP 400 errors) or cost you thousands in over-provisioned capacity.- If you ignore Global Tables, your users in Europe will experience 200ms+ latency when reading from a US-based table.- If you don’t use TTL, your storage costs will balloon with stale data (e.g., expired session tokens, old logs).- If you skip Streams, you’ll miss real-time triggers for analytics, caching, or cross-region replication.
This guide gives you the exact commands, configurations, and pitfalls to deploy DynamoDB like a pro—whether you’re building a new feature or fixing a legacy system.
dynamodb:*
dax:*
lambda:*
aws --version
aws dynamodb create-table \ --table-name Orders \ --attribute-definitions \ AttributeName=OrderID,AttributeType=S \ AttributeName=OrderDate,AttributeType=S \ --key-schema \ AttributeName=OrderID,KeyType=HASH \ AttributeName=OrderDate,KeyType=RANGE \ --provisioned-throughput \ ReadCapacityUnits=5,WriteCapacityUnits=5 \ --region us-east-1
Verify:
aws dynamodb describe-table --table-name Orders --query "Table.TableStatus" # Expected output: "ACTIVE"
aws dynamodb update-time-to-live \ --table-name Orders \ --time-to-live-specification "Enabled=true,AttributeName=ExpiryTime"
aws dynamodb describe-time-to-live --table-name Orders # Expected output: {"TimeToLiveDescription": {"AttributeName": "ExpiryTime", "TimeToLiveStatus": "ENABLED"}}
aws dynamodb put-item \ --table-name Orders \ --item '{ "OrderID": {"S": "ORD123"}, "OrderDate": {"S": "2023-10-01"}, "Customer": {"S": "Alice"}, "ExpiryTime": {"N": "1700000000"} # Unix timestamp (Nov 15, 2023) }'
Check TTL deletion (after expiry):
aws dynamodb get-item --table-name Orders --key '{"OrderID": {"S": "ORD123"}, "OrderDate": {"S": "2023-10-01"}}' # Expected output: {} (item deleted)
aws dynamodb update-table \ --table-name Orders \ --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES
Get Stream ARN (needed for Lambda triggers):
aws dynamodb describe-table --table-name Orders --query "Table.LatestStreamArn" # Expected output: "arn:aws:dynamodb:us-east-1:123456789012:table/Orders/stream/2023-10-01T00:00:00.000"
aws dax create-cluster \ --cluster-name OrdersDAX \ --node-type dax.r4.large \ --replication-factor 2 \ --iam-role-arn arn:aws:iam::123456789012:role/DAXServiceRole \ --region us-east-1
Get DAX Endpoint:
aws dax describe-clusters --query "Clusters[0].ClusterDiscoveryEndpoint" # Expected output: {"Address": "ordersdax.abc123.dax-clusters.us-east-1.amazonaws.com", "Port": 8111}
aws dynamodb create-global-table \ --global-table-name Orders \ --replication-group RegionName=us-east-1,RegionName=eu-west-1
aws dynamodb describe-global-table --global-table-name Orders # Expected output: {"GlobalTableDescription": {"ReplicationGroup": [{"RegionName": "us-east-1"}, {"RegionName": "eu-west-1"}]}}
import boto3 from boto3.dynamodb.conditions import Key # DAX endpoint (replace with your cluster endpoint) dax_endpoint = "ordersdax.abc123.dax-clusters.us-east-1.amazonaws.com:8111" # Use DAX for reads dynamodb = boto3.client('dynamodb', endpoint_url=f"https://{dax_endpoint}") dax = boto3.client('dax', endpoint_url=f"dax://{dax_endpoint}") # Write to us-east-1 (replicates to eu-west-1) dynamodb.put_item( TableName="Orders", Item={ "OrderID": {"S": "ORD456"}, "OrderDate": {"S": "2023-10-02"}, "Customer": {"S": "Bob"} } ) # Read from DAX (microsecond latency) response = dax.get_item( TableName="Orders", Key={"OrderID": {"S": "ORD456"}, "OrderDate": {"S": "2023-10-02"}} ) print(response["Item"])
dynamodb:GetItem
bash aws application-autoscaling register-scalable-target \ --service-namespace dynamodb \ --resource-id table/Orders \ --scalable-dimension dynamodb:table:ReadCapacityUnits \ --min-capacity 5 \ --max-capacity 100
bash aws dynamodb update-continuous-backups \ --table-name Orders \ --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true
ThrottledRequests
ConsumedReadCapacityUnits
CacheHitRatio
IteratorAge
UserID#Timestamp
UserID
ConditionExpression
Why: Global Tables reduce latency, DAX caches reads.
"Your app is throttled with HTTP 400 errors. What’s the issue?"
Fix: Increase capacity or switch to on-demand.
"How do you auto-delete expired session tokens?"
ExpiryTime
Scenario: Your team needs to log user actions (e.g., clicks, purchases) in real-time for analytics. Design a DynamoDB table that: 1. Auto-deletes logs after 30 days.2. Triggers a Lambda function for each new log.3. Scales to 10K writes/sec.
Solution:
# 1. Create table with TTL aws dynamodb create-table \ --table-name UserActions \ --attribute-definitions AttributeName=UserID,AttributeType=S AttributeName=Timestamp,AttributeType=N \ --key-schema AttributeName=UserID,KeyType=HASH AttributeName=Timestamp,KeyType=RANGE \ --provisioned-throughput ReadCapacityUnits=1000,WriteCapacityUnits=10000 \ --stream-specification StreamEnabled=true,StreamViewType=NEW_IMAGE \ --time-to-live-specification Enabled=true,AttributeName=ExpiryTime # 2. Enable Lambda trigger (replace with your Lambda ARN) aws lambda create-event-source-mapping \ --function-name ProcessUserActions \ --event-source "arn:aws:dynamodb:us-east-1:123456789012:table/UserActions/stream/2023-10-01T00:00:00.000" \ --batch-size 100 \ --starting-position LATEST
Why it works: - TTL auto-deletes old logs.- Streams trigger Lambda for real-time processing.- High WCU handles 10K writes/sec.
aws dynamodb create-table
--provisioned-throughput
--billing-mode PAY_PER_REQUEST
dax://cluster-name.abc123.dax-clusters.region.amazonaws.com:8111
StreamViewType=NEW_AND_OLD_IMAGES
AttributeName
Status=Active
CacheHitRatio < 90%
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.