Amazon DynamoDB

Amazon DynamoDB

NoSQL database. Single-digit millisecond latency at any scale.

database
<10ms
Latency
Single-digit milliseconds
Unlimited
Throughput
On-demand or provisioned
400KB
Max Item
Single item limit
99.999%
SLA
Global Tables

What is DynamoDB?

Key-value and document database. No servers to manage. Scales automatically. Single-digit millisecond response times. Handles millions of requests per second.

Think of it like a massive key-value filing cabinet

You give each item a unique key (partition key), optionally with a sort key for organization. DynamoDB instantly finds any item without searching through everything.

Key Features

key

Key-Value & Document

Flexible data model. Store JSON documents or simple key-value pairs.

settings

Auto Scaling

On-demand mode scales automatically. No capacity planning needed.

globe-2

Global Tables

Multi-region replication. Active-active across regions.

activity

DynamoDB Streams

Capture changes in real-time. Trigger Lambda functions.

zap

DAX Cache

In-memory cache. Microsecond latency for reads.

lock

Transactions

ACID transactions across multiple items and tables.

When to Use

  • Need single-digit ms latency
  • Serverless applications
  • Session storage
  • Gaming leaderboards
  • IoT data ingestion
  • Shopping carts

When Not to Use

  • Complex SQL queries → RDS/Aurora
  • Need joins → RDS
  • Data warehouse → Redshift
  • Graph relationships → Neptune
  • Full-text search → OpenSearch
  • Items over 400KB → S3

Prerequisites

  • An AWS account (free tier: 25GB storage, 25 RCU, 25 WCU)
  • AWS CLI configured (optional)
  • Basic understanding of NoSQL concepts

AWS Console Steps

1

Open DynamoDB Dashboard

Navigate to DynamoDB in the AWS Console

2

Create Table

Click 'Create table' and enter a table name

3

Define Partition Key

Enter partition key name and type (String, Number, Binary)

4

Optional: Add Sort Key

Add sort key for range queries and hierarchical data

5

Choose Capacity Mode

Select On-demand (pay per request) or Provisioned

6

Create and Use

Click Create and start adding items via console or SDK

Pro Tips8

Partition key design

Use high-cardinality keys like userId or orderId. Avoid timestamps or status codes as partition keys.

GSI vs LSI

LSI: same partition key, strongly consistent, created at table creation. GSI: any key, eventually consistent, add anytime.

On-demand vs provisioned

Start with on-demand for new workloads. Switch to provisioned for stable traffic and 77% savings.

TTL for auto-cleanup

Enable TTL to delete expired items at no cost. Perfect for sessions and temporary data.

DynamoDB Streams

Trigger Lambda on changes. Records retained for 24 hours.

Transactions

Cost 2x normal operations. Use only when you need atomicity across items.

Single-table design

Store multiple entity types in one table. Reduces costs and enables atomic transactions.

DAX caching

Use for read-heavy workloads needing microsecond latency. Not for writes or strong consistency.

Key Facts8

Max item size: 400KB

GSI limit: 20 per table

LSI limit: 5 per table (created at table creation only)

Partition throughput: 1,000 WCU and 3,000 RCU per partition

Transaction limit: 100 items or 4MB per transaction

Batch write: 25 items max per request

Batch get: 100 items max per request

Query/Scan: 1MB per operation (paginate for more)

AWS Certification Practice4

Need sub-millisecond read latency

Query by non-primary key attribute

Unpredictable traffic spikes

Auto-delete expired sessions

Documentation