← all topics

System design / DynamoDB

One million writes.
No nodes to provision.

Size request capacity, design the keys, and prepare the service for traffic. AWS handles the machines; your data model still determines how well the workload scales.

Ordinary writes, items up to 1 KB
1M units/s
Base table only
Provisioned at 70% utilization
~1.43M WCU
Quota and readiness checks required
Key design
PK + SK
Conversation/bucket + message order

What replaces Cassandra node math? Calculate capacity units from item size and operation rate. Do not multiply by a replication factor or choose a physical partition count.

01 / DynamoDB

Define the workload

Continue the Messenger example: one million new messages per second, sustained. Assume ordinary, non-transactional writes to one table, with no secondary indexes in the initial calculation.

AssumptionValue
Write rate1,000,000 new items per second
Complete item sizeAt most 1 KB, including keys and attribute names
HistoryYears, based on product requirements
AttachmentsObject storage; the item contains references
Main queryLatest messages in a conversation, then paginate backward
RegionOne AWS Region in the initial calculation

DynamoDB uses 1 KB = 1,024 bytes for write-capacity sizing. Count the complete item. A 1 KB message body plus keys and metadata may cross the threshold and require two write units.

02 / DynamoDB

Calculate write capacity

One write capacity unit supports one ordinary write per second for an item up to 1 KB. Each item is rounded up independently.

WCU per ordinary write = ceil(item bytes ÷ 1,024)

For items at most 1 KB:
1M writes/s × 1 WCU = 1M WCU

Provisioned capacity at 70% target utilization:
1M ÷ 0.70 ≈ 1.43M WCU
Complete item sizeUnits per ordinary writeUnits/s at 1M writes/s
Up to 1 KB11M
Over 1 KB, up to 2 KB22M
Over 2 KB, up to 3 KB33M

This is the base table only. Transactional writes consume twice the write units for the same item size. Secondary indexes and cross-region replication require separate accounting.

Do not multiply by RF 3. Regional replication is built into DynamoDB's service. You do not provision an RF setting or count replica mutations as you did for self-managed Cassandra.

03 / DynamoDB

Choose the capacity mode

You configure table capacity behavior rather than an EC2 instance count.

ModeWhat you configureHow to use it in this example
ProvisionedRead/write units, autoscaling targets, minimum and maximum capacityPrepare about 1.43M WCU for the assumed writes; size reads separately
On-demandRequest-based billing, optional maximum throughput, sufficient warm throughput and quotasPrepare for 1M write units/s plus the desired traffic margin; no provisioned WCU reservation

Provisioned mode can suit predictable usage. On-demand reduces capacity management for variable usage. Compare costs for the actual traffic pattern; neither changes the need for evenly distributed keys.

The 70% target is our planning choice. Autoscaling reacts over time; set sufficient initial or minimum provisioned capacity before a known high-rate workload arrives.

04 / DynamoDB

Prepare quotas and warm throughput

Do this before switching on a million writes per second.

  1. Check the current table, index, and account quotas. Request increases for the chosen capacity and Region.
  2. Check the table's warm throughput, which indicates capacity ready to serve immediately.
  3. Pre-warm for a known jump if necessary, and wait for preparation to complete.
  4. For provisioned mode, configure enough provisioned capacity. For on-demand, ensure any configured maximum does not block the target.
  5. Prepare secondary indexes too, if present.

These are different controls. Warm throughput does not override quotas or a provisioned capacity limit. Explicit pre-warming may incur charges.

On-demand does not mean an arbitrary sudden traffic jump is guaranteed. Verify readiness and test a controlled ramp.

05 / DynamoDB

Create the table and key schema

DynamoDB has tables directly within an AWS account and Region. There is no Cassandra-style keyspace, seed list, or token configuration.

SettingMessenger choice
Table nameMessages
Partition-key attributePK, type String
Sort-key attributeSK, type String
Capacity modeProvisioned or on-demand
Other attributesAdded on individual items; no fixed columns required

The application encodes conversation ID and a daily bucket into one partition-key attribute. A sortable timestamp plus a unique ID forms the sort key.

example-message.json · JSON{ "PK": "CONV#123#DAY#2026-09-30", "SK": "2026-09-30T12:34:56.123Z#message-abc", "sender_id": "user-456", "body": "See you at six." }

This is a plain JSON item illustration, not an AWS CLI request. Use consistent timestamp formatting and unique IDs. The actual string order defines the timeline; strict conversation sequencing would need an explicit sequencing design.

For a composite primary key, PK + SK uniquely identifies the item. Multiple items share a PK and differ by SK. DynamoDB also permits a simple primary key containing only the partition key.

06 / DynamoDB

Read conversation history efficiently

Use Query with an exact partition-key value. Set ScanIndexForward=false for descending sort-key order and paginate with LastEvaluatedKey.

PK = CONV#123#DAY#2026-09-30
Order = descending by SK
Return a page, then continue with its pagination key
Move into older day buckets when needed

Unlike the Cassandra example, there is no table-level CLUSTERING ORDER BY clause. The sort key defines order, and each Query chooses forward or reverse traversal.

Filtering after reading does not remove the read capacity consumed. Design keys and indexes around the queries instead of scanning the whole table.

The application needs a way to locate older populated buckets. A deterministic scheme or conversation metadata can help avoid probing long runs of empty dates.

07 / DynamoDB

Check key distribution and hot traffic

A partition-key value is a logical grouping. A physical partition is storage infrastructure managed by DynamoDB. They are not a one-to-one relationship, and you do not set the physical partition count.

A physical partition supports up to 1,000 write units/s and 3,000 read units/s. These are capacity units, not operations of arbitrary size.

1M write units/s ÷ 1,000 per physical partition
= at least 1,000 partitions' worth of write capacity

This is a capacity sanity check, not a configuration command or a prediction of the exact number AWS will allocate. AWS may allocate more because of storage, headroom, and distribution.

Many conversations spread traffic. A single extremely busy conversation can still concentrate writes. Adaptive capacity helps uneven traffic, but it does not make one hot item or a narrow write range unlimited.

Shard exceptional conversations when necessary

CONV#123#DAY#2026-09-30#SHARD#0
CONV#123#DAY#2026-09-30#SHARD#1
CONV#123#DAY#2026-09-30#SHARD#2

Route messages across shards, for example with a stable hash of the message ID. Reads must query the shards and merge by sort key. A daily bucket bounds history, while the shard spreads current writes.

08 / DynamoDB

Size reads separately

For individual ordinary item reads, memorize:

Read typeCapacity for an item up to 4 KB
Strongly consistent1 read capacity unit per read/s
Eventually consistent0.5 read capacity units per read/s
Transactional2 read capacity units per read/s

Multiply by the appropriate size increments and rate. A Query reading many items has its own aggregate byte accounting; do not simply treat every returned row as a separate GetItem request.

Strongly consistent reads are available on the base table, but global secondary indexes provide eventually consistent reads. Choose consistency from the product requirements. Cache recent history when repeated reads justify it.

09 / DynamoDB

Count the additional work

Our 1M-unit estimate covers one ordinary write to the base table. Messenger also has conversation lists, unread state, search, and delivery. Decide which operations really need another database write.

FeatureScaling implication
Global secondary indexAdditional write units and storage; its key distribution can create a bottleneck
Read cursorStore a per-user/conversation position rather than changing every message
SearchOften a separate asynchronously maintained search system
BatchWriteItemUp to 25 put/delete operations per call; fewer round trips, not fewer write units
TransactionsExtra capacity cost; use where atomic multi-item changes are required
Global tablesCross-region replication and cost require a separate design

A throttled GSI can apply backpressure to base-table writes. Batch requests can return unprocessed items; retry those with backoff. Do not resend successful entries blindly.

10 / DynamoDB

Plan years of retained history

DynamoDB grows storage without you adding nodes. The bytes and their cost still exist.

If each item is exactly 1,000 bytes:
1M items/s × 1,000 bytes = 1 GB/s
One year at that sustained rate = 31.536 PB of item data

This uses decimal units for the volume example. Items exactly 1,024 bytes would produce about 32.29 PB/year. Actual billing also reflects storage overhead and indexes.

Do not multiply the regional table's storage bill by three for internal replication. Price the service's actual storage rules; additional Regions and indexes are separate.

No automatic expiry is required for message history. If you choose TTL, expiry is asynchronous and does not archive data. Preserve history elsewhere before relying on expiration, and define how users retrieve, search, edit, or delete old messages.

11 / DynamoDB

Connect clients and operate the table

Applications use an AWS SDK, Region, table name, and IAM permissions. They connect to the DynamoDB service endpoint. AWS handles the physical node routing.

Write path

  1. Generate a stable message ID and bucket.
  2. Write the item with its PK and SK.
  3. Handle throttling or transient failures with bounded retries and backoff.
  4. Notify recipients according to the chosen persistence acknowledgment contract.

Retries should target the same key. If overwriting an existing item is unacceptable, use a conditional write and handle the already-existing case deliberately. This does not make external notifications exactly once.

Monitor before choosing a lever

Track throttling reasons, consumed capacity, latency, hot keys, index capacity, and queue lag if ingestion is asynchronous. Validate item sizes and observe the actual units consumed.

12 / DynamoDB

The scaling levers

ProblemLever
Total request capacity exhaustedIncrease provisioned capacity, adjust autoscaling bounds, or use on-demand
Known abrupt traffic jumpPrepare warm throughput and quotas in advance
Hot key or write rangeChange key design, shard writes, or coalesce eligible updates
Repeated readsCache recent data and choose acceptable read consistency
Oversized itemsReduce item size; store attachments separately
Index throttlingIncrease index capacity or redesign its keys
Too many round tripsUse bounded concurrency and supported batch APIs
Retention costMeasure compression at the application/data-design level, reduce unnecessary attributes, or design a historical tier

Batching reduces client overhead but does not discount item capacity units. More total table capacity does not cure an intrinsically hot access pattern.

13 / DynamoDB

The two-minute interview answer

“For one million ordinary writes per second with complete items up to 1 KB, I need one million write units per second. In provisioned mode, I'd target roughly 1.43 million WCU with headroom, arrange quota increases, and prepare warm throughput. I'd key messages by conversation and bucket with a sortable message ID, shard hot conversations, and size reads and indexes separately. AWS manages the nodes and regional replication. Years of retained history remains a storage-cost decision.”

Workload → units per operation → capacity mode → quotas and readiness → table keys → hot-key checks → reads, indexes, and retention → load test.

14 / DynamoDB

Sources and scope

This is an interview sizing model, not a load-tested deployment. The 70% utilization target is a planning assumption. Service quotas and prices should be checked for the intended Region.