AWS Builder Center
Amazon DynamoDB: Architecture, Partitioning, Scaling, and High-Performance NoSQL Design

Amazon DynamoDB: Architecture, Partitioning, Scaling, and High-Performance NoSQL Design

Explore how DynamoDB achieves single-digit millisecond latency at massive scale through automatic partitioning, distributed storage, replication, and serverless operations. Learn data modeling, indexing strategies, scaling patterns, global tables, streams, and production-ready architecture designs.

Introduction

Modern applications generate massive amounts of data and require databases that can scale horizontally without sacrificing performance. Traditional relational databases often struggle with partitioning, replication, and handling millions of requests per second.
Amazon DynamoDB is AWS's fully managed NoSQL database service designed to provide predictable performance, automatic scaling, and single-digit millisecond latency at virtually any scale.
DynamoDB powers some of AWS's largest services and is used by organizations building high-scale applications such as e-commerce platforms, gaming systems, IoT backends, SaaS products, and real-time analytics platforms.

What is Amazon DynamoDB?

Amazon DynamoDB is a fully managed NoSQL database service that provides:
  • Key-Value Storage
  • Document Storage
  • Automatic Scaling
  • Serverless Operations
  • Global Replication
  • High Availability
  • Built-in Security
DynamoDB eliminates:
  • Database servers
  • Capacity planning
  • Replication management
  • Operating system maintenance
  • Backup infrastructure

Why AWS Built DynamoDB

Traditional relational databases face scaling challenges.
1
2
3
4
5
6
7
8
9
10
Application
│
▼
Relational Database
│
▼
Vertical Scaling
│
▼
Hardware Limits
Problems:
  • Single-node bottlenecks
  • Expensive hardware upgrades
  • Complex sharding
  • Replication management
  • Operational overhead
AWS created DynamoDB to achieve:
1
2
3
4
5
Infinite Scale
+
Low Latency
+
Managed Operations

DynamoDB Architecture

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Application
│
▼
DynamoDB API
│
▼
Request Router Layer
│
┌──────────────┼──────────────┐
▼ ▼ ▼
Partition A Partition B Partition C
│ │ │
▼ ▼ ▼
Storage Storage Storage
DynamoDB automatically partitions data and distributes requests across storage nodes.

Core Concepts

Table

A collection of items.
Example:
1
2
3
4
Users
Orders
Products
Sessions

Item

Equivalent to a row.
1
2
3
4
5
{
"userId": "123",
"name": "Ashutosh",
"email": "user@example.com"
}

Attribute

Equivalent to a column.
1
2
3
{
"userId": "123"
}

Partition Key

The most important concept in DynamoDB.
1
userId
Example:
1
2
3
{
"userId": "123"
}
Partition key determines:
  • Data location
  • Request distribution
  • Scalability

Composite Primary Key

1
2
3
Partition Key
+
Sort Key
Example:
1
2
customerId
orderId
1
2
3
4
{
"customerId": "123",
"orderId": "1001"
}

Internal Partitioning

DynamoDB automatically creates partitions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Users Table
│
▼
+----------------+
| Partition A |
+----------------+

+----------------+
| Partition B |
+----------------+

+----------------+
| Partition C |
+----------------+
Hash Function:
1
2
3
4
Hash(userId)
│
▼
Partition Selection

Request Flow

Write Request

1
2
3
4
5
6
7
8
9
10
11
12
13
Application
│
▼
DynamoDB API
│
▼
Request Router
│
▼
Target Partition
│
▼
Storage Nodes

Read Request

1
2
3
4
5
6
7
8
9
10
11
12
13
Application
│
▼
DynamoDB API
│
▼
Request Router
│
▼
Partition
│
▼
Response

Replication Architecture

Every partition is replicated.
1
2
3
4
5
Partition
│
┌──┼──┐
▼ ▼ ▼
AZ1 AZ2 AZ3
Benefits:
  • High availability
  • Durability
  • Automatic failover

Secondary Indexes

Global Secondary Index (GSI)

Primary Table:
1
2
3
4
{
"userId": "123",
"email": "user@example.com"
}
Query by email:
1
2
GSI
└── email

Local Secondary Index (LSI)

1
2
Partition Key Same
Sort Key Different
Useful for alternative query patterns.

DynamoDB Streams

Captures item changes.
1
2
3
Insert
Update
Delete
Architecture:
1
2
3
4
5
6
7
DynamoDB
│
▼
Streams
│
▼
Lambda
Use Cases:
  • Event sourcing
  • Audit logging
  • Real-time processing

Time To Live (TTL)

Automatically deletes records.
1
2
3
4
{
"sessionId": "123",
"expiresAt": 1750000000
}
Use Cases:
  • Sessions
  • Tokens
  • Temporary records

Global Tables

Multi-region replication.
1
2
3
4
5
6
7
8
9
10
US-East-1
│
▼
Global Replication
│
▼
Europe
│
▼
Asia
Benefits:
  • Disaster Recovery
  • Low Latency
  • Global Applications

Creating a Table

AWS CLI:
1
2
3
4
5
6
7
aws dynamodb create-table \
--table-name Users \
--attribute-definitions \
AttributeName=userId,AttributeType=S \
--key-schema \
AttributeName=userId,KeyType=HASH \
--billing-mode PAY_PER_REQUEST

Insert Item

1
2
3
4
5
6
aws dynamodb put-item \
--table-name Users \
--item '{
"userId":{"S":"123"},
"name":{"S":"Ashutosh"}
}'

Java Example

1
2
3
4
5
6
7
8
9
10
11
12
13
DynamoDbClient dynamoDb =
DynamoDbClient.create();

PutItemRequest request =
PutItemRequest.builder()
.tableName("Users")
.item(Map.of(
"userId", AttributeValue.fromS("123"),
"name", AttributeValue.fromS("Ashutosh")
))
.build();

dynamoDb.putItem(request);

Python Example

1
2
3
4
5
6
7
8
9
10
import boto3

table = boto3.resource("dynamodb").Table("Users")

table.put_item(
Item={
"userId": "123",
"name": "Ashutosh"
}
)

DynamoDB + Lambda Architecture

1
2
3
4
5
6
7
API Gateway
│
▼
Lambda
│
▼
DynamoDB
Common in serverless applications.

DynamoDB + Microservices

1
2
3
4
5
6
7
8
9
10
11
12
13
14
User Service
│
▼
Users Table

Order Service
│
▼
Orders Table

Payment Service
│
▼
Payments Table
Single-table design is also common for high-performance systems.

Cost Optimization

  1. Use On-Demand mode for unpredictable workloads.
  2. Use Provisioned Capacity for stable workloads.
  3. Enable Auto Scaling.
  4. Design partition keys carefully.
  5. Use TTL to remove stale data.
  6. Avoid unnecessary scans.
  7. Use GSIs selectively.

Best Practices

  1. Design access patterns first.
  2. Avoid hot partitions.
  3. Prefer Query over Scan.
  4. Use GSIs carefully.
  5. Enable Point-in-Time Recovery.
  6. Use DynamoDB Streams for events.
  7. Monitor throttling metrics.
  8. Use Global Tables for global applications.

Common Interview Questions

Why is DynamoDB fast?

Data is partitioned and distributed across many storage nodes, allowing horizontal scaling and low-latency access.

What causes hot partitions?

Uneven partition key distribution causing excessive traffic to a small number of partitions.

Difference between GSI and LSI?

GSI uses a different partition key, while LSI shares the same partition key but allows different sort keys.

What is DynamoDB Streams?

A change data capture mechanism that records item-level modifications.

What are Global Tables?

Multi-region active-active DynamoDB tables providing low-latency global access.

Real-World Example

An e-commerce company handles:
  • 100 million users
  • 500 million products
  • 10 billion requests/day
Architecture:
1
2
3
4
5
6
7
8
9
10
11
12
13
CloudFront
│
▼
API Gateway
│
▼
Lambda
│
▼
DynamoDB
│
▼
Global Tables
Peak traffic:
1
50 Million Requests/Minute
DynamoDB automatically scales partitions and maintains low latency without database administrators managing clusters.

Conclusion

Amazon DynamoDB is one of AWS's most important cloud-native services. By combining automatic partitioning, built-in replication, serverless operations, and predictable performance, DynamoDB enables developers to build highly scalable applications without managing database infrastructure. It is particularly valuable for microservices, event-driven systems, serverless applications, gaming platforms, IoT workloads, and large-scale SaaS systems.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article