1. What is DynamoDB?

Amazon DynamoDB is a fully managed, serverless, key-value and document NoSQL database. It delivers single-digit millisecond performance at any scale with built-in security, backup, and in-memory caching.

Core Concept DynamoDB is serverless: no servers to provision, no OS to patch, no capacity to plan (in on-demand mode). It automatically scales to handle trillions of requests per day. Data is replicated across 3 AZs within a Region for high availability. It is the go-to NoSQL database on AWS.

2. Key Characteristics

  1. Fully managed, serverless — no infrastructure to manage
  2. Key-value AND document data model (flexible schema)
  3. Single-digit millisecond latency at any scale
  4. Data replicated across 3 AZs automatically
  5. Supports ACID transactions
  6. Event-driven programming via DynamoDB Streams
  7. Encryption at rest (KMS) by default
  8. Maximum item size: 400 KB
  9. Integrated with IAM for fine-grained access control

3. DynamoDB Data Model


Tables, Items, and Attributes

  1. Table: A collection of items (like a table in a relational DB, but schema-less).
  2. Item: A single record in a table (like a row). Each item can have different attributes.
  3. Attribute: A data element on an item (like a column, but not all items need the same attributes).


Primary Key (Required)

Every table must have a primary key defined at creation. It uniquely identifies each item. Two options:

Choosing a Good Partition Key The partition key determines data distribution. A bad PK (e.g., "country" with only 5 values) creates hot partitions. A good PK has high cardinality (many unique values) and distributes access evenly. Examples of good PKs: UserID, DeviceID, SessionID.

4. Read/Write Capacity


Capacity Modes

Capacity Unit Calculations

Capacity Calculation Examples:

Write: 10 items/sec, each 2.5 KB
  Each item = ceil(2.5/1) = 3 WCU
  Total = 10 × 3 = 30 WCU

Read (Strongly Consistent): 20 items/sec, each 6 KB
  Each item = ceil(6/4) = 2 RCU
  Total = 20 × 2 = 40 RCU

Read (Eventually Consistent): 20 items/sec, each 6 KB
  Total = 40 / 2 = 20 RCU (half the strongly consistent)

5. Secondary Indexes

Indexes allow you to query data using different attributes than the table’s primary key.

LSI vs GSI LSI = same partition key, different sort key. Created at table creation only. Shares capacity. GSI = completely different key schema. Can be added anytime. Has own capacity. GSI is more flexible and more commonly used. If the exam asks about querying by a non-key attribute, the answer is usually GSI.

6. DynamoDB API Operations

7. When to use

Use DynamoDB when you need a fully managed, serverless NoSQL database with single-digit millisecond performance at any scale.

Key exam triggers:

  1. "NoSQL"
  2. "key-value"
  3. "serverless database"
  4. "single-digit millisecond latency"
  5. "massive scale"
  6. "session store"
  7. "gaming leaderboard"

Common scenarios:

  1. Session storage for web/mobile apps.
  2. Gaming leaderboards, player profiles.
  3. IoT device state and telemetry.
  4. Shopping carts, user preferences.
  5. Real-time bidding, ad tech.
  6. Any workload needing predictable low-latency at a massive scale.


Important Warning Scan reads EVERY item in the table and is very expensive on large tables. Always prefer Query (which targets a specific partition key) over Scan. If you must scan, use Parallel Scan and apply filters to reduce the amount of returned data. The exam tests this: if you see "improve DynamoDB performance," the answer often involves replacing Scan with Query + GSI.


Exam Tip
DynamoDB Fundamentals: Max item = 400 KB. PK = partition key (or PK + SK). On-Demand = no planning, more expensive. Provisioned = set RCU/WCU + auto scaling. 1 WCU = 1 write/s for 1 KB. 1 RCU = 1 strongly consistent read/s for 4 KB (or 2 eventually consistent). GSI = flexible, own capacity, eventually consistent only. LSI = created at table time only, shares capacity. Always prefer Query over Scan.