Fatskills
Practice. Master. Repeat.
Study Guide: TECH **AWS DynamoDB Deep Dive: RCUs/WCUs, Global Tables, DAX, Streams, TTL**
Source: https://www.fatskills.com/aws-certified-solutions-architect-associate/chapter/tech-aws-dynamodb-deep-dive-rcuswcus-global-tables-dax-streams-ttl

TECH **AWS DynamoDB Deep Dive: RCUs/WCUs, Global Tables, DAX, Streams, TTL**

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~8 min read

AWS DynamoDB Deep Dive: RCUs/WCUs, Global Tables, DAX, Streams, TTL

Hyper-practical, zero-fluff guide for real projects & AWS SAA exam


1. What This Is & Why It Matters

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.


2. Core Concepts & Components


? DynamoDB Table

  • Definition: A collection of items (rows) with a primary key (partition key + optional sort key).
  • Production Insight: DynamoDB tables are schema-less—you can add new attributes without altering the table. But if you don’t define a partition key wisely, you’ll hit "hot partitions" (uneven load distribution).

? Read Capacity Units (RCUs)

  • Definition: 1 RCU = 1 strongly consistent read per second for an item ≤4 KB (or 2 eventually consistent reads).
  • Production Insight: If you read a 10 KB item, you consume 3 RCUs (10 KB / 4 KB = 2.5 → rounded up to 3). Always use eventually consistent reads unless you need strong consistency (halves RCU cost).

? Write Capacity Units (WCUs)

  • Definition: 1 WCU = 1 write per second for an item ≤1 KB.
  • Production Insight: A 2.5 KB item consumes 3 WCUs. Batch writes (BatchWriteItem) are more efficient—they reduce WCU consumption by up to 25x.

? On-Demand vs. Provisioned Capacity

  • On-Demand: Pay per request (scales automatically). Best for unpredictable workloads.
  • Provisioned: Set RCU/WCU limits. Best for predictable workloads (cheaper at scale).
  • Production Insight: Switching between modes takes ~5 minutes—plan for downtime if you’re near capacity limits.

? Global Tables

  • Definition: Multi-region, active-active replication for DynamoDB tables.
  • Production Insight: Latency drops from 200ms to 50ms for global users. But conflicts can occur (last writer wins by default). Use conditional writes to avoid overwrites.

? DynamoDB Accelerator (DAX)

  • Definition: In-memory cache for DynamoDB (microsecond latency).
  • Production Insight: Reduces RCU costs by 90% for read-heavy workloads. But not for write-heavy apps (DAX doesn’t cache writes).

? DynamoDB Streams

  • Definition: Time-ordered sequence of item-level changes (inserts, updates, deletes).
  • Production Insight: Enable Streams to trigger Lambda functions for real-time processing (e.g., analytics, notifications). Streams expire after 24 hours—process them quickly!

? Time to Live (TTL)

  • Definition: Auto-delete expired items based on a timestamp attribute.
  • Production Insight: Saves 30-50% on storage costs for ephemeral data (e.g., session tokens, logs). TTL deletions are free (no WCU cost).


3. Step-by-Step Hands-On: Deploy a Global DynamoDB Table with DAX & TTL


Prerequisites

  • AWS account with admin IAM permissions (or at least dynamodb:*, dax:*, lambda:*).
  • AWS CLI installed (aws --version).
  • A test app (we’ll use a Python script).


Step 1: Create a DynamoDB Table with Provisioned Capacity

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"


Step 2: Enable TTL for Auto-Expiring Orders

aws dynamodb update-time-to-live \
  --table-name Orders \
  --time-to-live-specification "Enabled=true,AttributeName=ExpiryTime"

Verify:


aws dynamodb describe-time-to-live --table-name Orders
# Expected output: {"TimeToLiveDescription": {"AttributeName": "ExpiryTime", "TimeToLiveStatus": "ENABLED"}}


Step 3: Add a Sample Item with TTL

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)


Step 4: Enable DynamoDB Streams

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"


Step 5: Deploy a DAX Cluster

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}


Step 6: Enable Global Table (Multi-Region Replication)

aws dynamodb create-global-table \
  --global-table-name Orders \
  --replication-group RegionName=us-east-1,RegionName=eu-west-1

Verify:


aws dynamodb describe-global-table --global-table-name Orders
# Expected output: {"GlobalTableDescription": {"ReplicationGroup": [{"RegionName": "us-east-1"}, {"RegionName": "eu-west-1"}]}}


Step 7: Test with Python (DAX + Global Table)

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"])


4. ? Production-Ready Best Practices


Security

  • Least privilege IAM: Grant dynamodb:GetItem only to read-only services.
  • Encrypt at rest: Enable AWS KMS encryption for sensitive tables.
  • VPC Endpoints: Use private VPC endpoints to avoid public internet exposure.

Cost Optimization

  • Use on-demand for unpredictable workloads (e.g., Black Friday sales).
  • Switch to provisioned for steady workloads (cheaper at scale).
  • Enable auto-scaling for provisioned tables: 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

Reliability & Maintainability

  • Global Tables for DR: Replicate to 2+ regions for high availability.
  • Backup & Restore: Enable PITR (Point-in-Time Recovery) for critical tables.
    bash aws dynamodb update-continuous-backups \
    --table-name Orders \
    --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true

Observability

  • CloudWatch Alarms: Monitor ThrottledRequests, ConsumedReadCapacityUnits.
  • DAX Metrics: Track CacheHitRatio (aim for >90%).
  • Streams Lag: Monitor IteratorAge (should be <100ms).


5. ⚠️ Common Mistakes & Traps

Mistake Symptom Fix/Prevention
Hot partitions (uneven key distribution) Throttling on a single partition key Use a high-cardinality partition key (e.g., UserID#Timestamp instead of just UserID).
Ignoring TTL Storage costs skyrocket Enable TTL for ephemeral data (e.g., session tokens, logs).
Strongly consistent reads everywhere High RCU costs Use eventually consistent reads unless you need strong consistency.
No DAX for write-heavy apps DAX cache misses, no performance gain DAX is for read-heavy workloads only—avoid for write-heavy apps.
Global Table conflicts Data overwrites in multi-region setups Use conditional writes (ConditionExpression) to prevent conflicts.


6. ? Exam/Certification Focus (AWS SAA)


Typical Question Patterns

  1. "You need a database for a gaming app with 10M users. Latency must be <10ms globally. What do you use?"
  2. Answer: DynamoDB Global Tables + DAX.
  3. Why: Global Tables reduce latency, DAX caches reads.

  4. "Your app is throttled with HTTP 400 errors. What’s the issue?"

  5. Answer: RCU/WCU limits exceeded.
  6. Fix: Increase capacity or switch to on-demand.

  7. "How do you auto-delete expired session tokens?"

  8. Answer: Enable TTL on the ExpiryTime attribute.

⚠️ Trap Distinctions

  • RCU vs. WCU: RCU is for reads, WCU for writes. 1 RCU = 2 eventually consistent reads.
  • DAX vs. ElastiCache: DAX is DynamoDB-specific; ElastiCache is generic (Redis/Memcached).
  • Global Tables vs. Cross-Region Replication: Global Tables are active-active; cross-region replication is active-passive.


7. ? Hands-On Challenge

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.


8. ? Rapid-Reference Crib Sheet

Command/Concept Key Details
aws dynamodb create-table --provisioned-throughput (RCU/WCU) or --billing-mode PAY_PER_REQUEST (on-demand).
RCU Calculation 1 RCU = 4 KB item (strongly consistent) or 8 KB (eventually consistent).
WCU Calculation 1 WCU = 1 KB item.
DAX Endpoint dax://cluster-name.abc123.dax-clusters.region.amazonaws.com:8111
Global Tables Replicate to 2+ regions. Last writer wins for conflicts.
Streams Enable with StreamViewType=NEW_AND_OLD_IMAGES. Expires after 24 hours.
TTL Set AttributeName to a Unix timestamp (e.g., ExpiryTime). Deletions are free.
⚠️ Hot Partitions Avoid low-cardinality partition keys (e.g., Status=Active).
⚠️ DAX Cache Misses If CacheHitRatio < 90%, your app isn’t read-heavy enough for DAX.


9. ? Where to Go Next

  1. AWS DynamoDB Developer Guide – Official docs.
  2. DynamoDB Deep Dive (AWS re:Invent) – Best practices from AWS experts.
  3. DAX Workshop – Hands-on DAX tutorial.
  4. DynamoDB Streams + Lambda – Real-time processing guide.


ADVERTISEMENT