Skip to main content

Chapter 2: Architecture and Partitioning

DynamoDB’s architecture represents a sophisticated blend of distributed systems principles: consistent hashing for data distribution, a request router layer for routing, storage nodes for durability, and automatic partitioning for scale. Architecturally, DynamoDB made a significant departure from the original Dynamo paper’s peer-to-peer design: it introduced a dedicated request routing layer that sits between clients and storage nodes, creating a clear separation between the API/authentication layer and the data storage layer. This layered architecture enables independent scaling of each tier and is the reason DynamoDB can handle traffic spikes by simply adding more router instances without touching storage nodes. Understanding this architecture is crucial for effective data modeling and performance optimization — many DynamoDB performance problems stem from not understanding how partitioning and routing work under the hood.
Chapter Goals:
  • Understand DynamoDB’s high-level architecture
  • Master consistent hashing and the hash ring concept
  • Learn how data is partitioned and distributed
  • Grasp request routing and storage node design
  • Understand auto-scaling and adaptive capacity

High-Level Architecture

System Components

DynamoDB’s architecture consists of several key layers:

Layer Responsibilities

Request Router Responsibilities
Key Point: The request router is stateless and can scale independently of storage nodes. This enables DynamoDB to handle traffic spikes without affecting storage.

Consistent Hashing

The Partitioning Problem

Before diving into consistent hashing, understand the problem it solves. Consistent hashing was originally proposed by David Karger et al. in 1997 for web caching (the paper “Consistent Hashing and Random Trees”), but its adoption in Dynamo and DynamoDB made it one of the most widely used distributed systems algorithms in production. The core insight is elegant: by mapping both nodes and keys onto the same hash ring, you can add or remove nodes while relocating only a small fraction of keys, avoiding the catastrophic data migration that plagues simple modulo-based hashing:

Naive Hashing Problems

Simple hash-based partitioning has a major flaw:

Consistent Hashing Solution

Consistent hashing minimizes data movement when nodes are added or removed:

How Consistent Hashing Works

Place nodes on the hash ring
Determine which node stores each key
Minimal data movement when adding nodes
Minimal data movement when removing nodes

Virtual Nodes (Tokens)

Real implementations use virtual nodes for better load distribution:

Partition Key and Data Distribution

Partition Key Hashing

Partition Size Limits

Partition Constraints:Each partition has hard limits:
When a partition exceeds limits, DynamoDB automatically splits it:

Choosing Good Partition Keys


Request Routing

Write Path

Read Path (Eventually Consistent)

Read Path (Strongly Consistent)


Auto-Scaling and Adaptive Capacity

Provisioned Capacity Mode

The Hot Partition Problem

Adaptive Capacity

DynamoDB’s solution to hot partitions:

Burst Capacity

On-Demand Capacity Mode


Key Takeaways

Chapter 2 Summary:
  1. Architecture Layers:
    • Request Router: Stateless, handles routing and throttling
    • Storage Nodes: Store data, handle replication
    • Control Plane: Manages partitions and scaling
  2. Consistent Hashing:
    • Minimizes data movement when nodes are added/removed
    • Uses hash ring (0 to 2³²-1)
    • Virtual nodes ensure even distribution
    • Only K/(N+1) keys move when adding a node
  3. Partitioning:
    • Partition key hashed with MD5
    • Each partition limited to 10GB, 3000 RCU, 1000 WCU
    • Automatic splitting when limits exceeded
    • Choose high-cardinality partition keys
  4. Request Routing:
    • Writes go to primary, replicate to 2 replicas (W=2)
    • Eventually consistent reads from any replica
    • Strongly consistent reads from primary only
    • Typical latency: 5-10ms
  5. Capacity Management:
    • Provisioned mode: Fixed capacity, cheaper for predictable loads
    • On-demand mode: Auto-scaling, pay-per-request
    • Adaptive capacity: Redistributes capacity to hot partitions
    • Burst capacity: Handles short traffic spikes
  6. Hot Partitions:
    • Occur when traffic is uneven across partitions
    • Mitigated by adaptive capacity
    • Best solved with better partition key design

Interview Questions

Difficulty: MediumStrong Answer:
Follow-up: What happens if hash distribution is uneven?Answer: Use virtual nodes (tokens). Each physical node gets 128+ positions on the ring, ensuring statistical even distribution.
Difficulty: MediumStrong Answer:
Difficulty: Medium-HardStrong Answer:
Difficulty: Easy-MediumStrong Answer:
Difficulty: HardScenario: Design partition key strategy for Twitter-like app with:
  • 100M users
  • Users post tweets
  • Users view their timeline (tweets from followers)
  • Popular users have millions of followers
Strong Answer:

What’s Next?

In Chapter 3: Data Model and Access Patterns, we’ll explore:
  • Tables, items, and attributes in detail
  • Primary keys: partition key vs composite key
  • Secondary indexes (GSI and LSI)
  • Data modeling patterns and anti-patterns

Continue to Chapter 3

Master DynamoDB’s data model and learn how to design effective schemas