Skip to content

Lab 9 · DynamoDB & ElastiCache

Performance · Est. time: 25–30 min · Cost: DynamoDB on-demand for a few items is effectively free (25 GB + limited free tier). ⚠️ ElastiCache is NOT Free Tier (it runs nodes hourly) — Part B is read-mostly/optional; delete any cluster promptly.

Goal. Create a DynamoDB table (serverless NoSQL), read/write items, and understand where DAX and ElastiCache fit — the caching layer of Topic 9.


Part A — DynamoDB table

  1. DynamoDB → Create table lab-orders, partition key orderId (String).
  2. Capacity mode: On-demand (no capacity to manage, pay per request).
  3. Explore items → Create item: {"orderId":"A1","total":42}. Add a couple more.
  4. Query/Scan to read them. Note the single-digit-millisecond responses.
aws dynamodb create-table --table-name lab-orders \
  --attribute-definitions AttributeName=orderId,AttributeType=S \
  --key-schema AttributeName=orderId,KeyType=HASH \
  --billing-mode PAY_PER_REQUEST
aws dynamodb put-item --table-name lab-orders \
  --item '{"orderId":{"S":"A1"},"total":{"N":"42"}}'
aws dynamodb get-item --table-name lab-orders --key '{"orderId":{"S":"A1"}}'

Points to internalize:

  • DynamoDB is multi-AZ by default (no config) — highly available out of the box.
  • For microsecond reads you'd add DAX (DynamoDB-native, API-compatible) — not ElastiCache.
  • For multi-Region active-active, enable Global Tables.

Part B — Caching concept (ElastiCache — optional)

Billing

An ElastiCache cluster runs nodes that bill hourly (not Free Tier). If you create one, use the smallest node and delete it within the hour.

  1. ElastiCache → Redis → Create a single small node cluster in your VPC.
  2. From an EC2 instance in the same VPC, connect with redis-cli -h <endpoint> and SET/GET a key.
  3. Delete the cluster immediately after.

What matters for the exam (no need to build it):

  • ElastiCache caches in front of a relational DB / app data / sessions. Redis = HA + persistence + rich types; Memcached = simple, multi-threaded, ephemeral.
  • DAX caches DynamoDB; CloudFront caches web content. Don't swap the three.

Teardown

  1. Delete the DynamoDB table lab-orders.
  2. Delete any ElastiCache cluster you created (stops the hourly bill).
aws dynamodb delete-table --table-name lab-orders

✅ What you should understand now

  • DynamoDB is serverless NoSQL, multi-AZ by default, single-digit-ms — great for key-value at scale with no servers.
  • On-demand capacity = pay per request, no provisioning; provisioned = set RCU/WCU for predictable load.
  • DAX = DynamoDB cache (microseconds); ElastiCache = relational/app cache; CloudFront = edge content cache.
  • Redis (HA/persistence/rich types) vs Memcached (simple ephemeral).
  • Global Tables make DynamoDB multi-Region active-active.

Related: Learn — Database & Caching Performance