Lesson 4 of 10 Amazon DynamoDB

Choosing a Capacity Mode and Calculating Read and Write Capacity Units

This lesson explains how DynamoDB throughput is billed, per request in on-demand mode or as provisioned read and write capacity units, and how to calculate the units a workload needs.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose between on-demand and provisioned capacity for a workload.
  • Calculate the read and write capacity units a workload needs for strongly consistent, eventually consistent and transactional requests.
  • Explain how burst capacity, adaptive capacity and the partition key affect uneven traffic.

Capacity modes

DynamoDB offers two capacity modes, which differ in how throughput is charged and in how much planning they require.

In on-demand mode, there is no capacity to configure. DynamoDB charges for each read and write request and adapts to traffic automatically, accommodating sudden increases up to double the table's previous peak at once. It suits new applications whose traffic is unknown, workloads with large unpredictable spikes, and tables that are idle much of the time, because an idle table costs only its storage. A maximum throughput can be set to cap cost.

In provisioned mode, you specify the read capacity units (RCUs) and write capacity units (WCUs) the table needs and pay for them every hour, whether used or not. Auto scaling adjusts the provisioned values towards a target utilisation, such as 70%, as traffic changes, but it reacts over minutes, so a sudden spike can be throttled before capacity rises. For steady, predictable traffic, provisioned mode costs less than on-demand, and reserved capacity reduces the price further.

The following table summarises the two modes.

ModeHow you payBest for
On-demandPer request; no capacity planningNew, unpredictable or spiky workloads
ProvisionedPer RCU and WCU per hour, with optional auto scalingSteady, predictable traffic at lower cost

When requests exceed capacity, DynamoDB returns ProvisionedThroughputExceededException and the AWS SDKs retry automatically with exponential backoff.

Calculating capacity units

Provisioned capacity is measured in read and write capacity units. Item sizes are rounded up to the unit size before the number of units required is calculated.

UnitCoversRound item size up to
1 WCUOne write per second of up to 1 KBThe next 1 KB
1 RCUOne strongly consistent read per second of up to 4 KB, or two eventually consistent readsThe next 4 KB

Transactional reads and writes cost twice as much. The method is always:

  1. Round the item size up

    Round to the next 1 KB for writes and the next 4 KB for reads.

  2. Multiply by the request rate

    Multiply the units for one item by the number of requests per second.

  3. Adjust for the read or write type

    Halve the result for eventually consistent reads; double it for transactions.

The following table applies the method to several workloads.

WorkloadCalculationResult
10 strongly consistent reads/s of 6 KB10 × ceil(6 / 4) = 10 × 220 RCU
Same, eventually consistent20 ÷ 210 RCU
20 strongly consistent reads/s of 9 KB20 × ceil(9 / 4) = 20 × 360 RCU (30 if eventually consistent)
10 writes/s of 2.5 KB10 × 330 WCU
5 transactional writes/s of 1.5 KB5 × 2 KB × 220 WCU

Uneven traffic

DynamoDB provides mechanisms that absorb uneven traffic across partitions. The following list describes these mechanisms and the role of the partition key.

  • Burst capacity keeps some unused capacity in reserve for short spikes.
  • Adaptive capacity shifts throughput towards busier partitions.
  • Neither can rescue a single key that needs more than one partition's limit of about 3,000 RCU or 1,000 WCU, so hot keys must be spread by design.
  • On-demand tables can also throttle if traffic suddenly grows to more than double its previous peak.
Worked example

Calculating capacity units

An application reads 80 items per second of 6 KB each and writes 40 items per second of 1.5 KB each.

Reads (strongly consistent):  6 KB / 4 KB = 1.5 -> round up to 2 RCU per read
                              80 reads/s x 2 RCU                 = 160 RCU
Reads (eventually consistent): half of that                       =  80 RCU
Reads (transactional):         double the strongly consistent    = 320 RCU

Writes: 1.5 KB / 1 KB = 1.5 -> round up to 2 WCU per write
        40 writes/s x 2 WCU                                       =  80 WCU
        Transactional writes: double                              = 160 WCU

Rounding up per item is where most calculation questions catch people out: a 6 KB item costs two read units, not one and a half. If traffic were unpredictable, on-demand mode would remove the need for this calculation entirely, at a higher price per request.

Check yourself

How many read capacity units are needed for 40 eventually consistent reads per second of 7 KB items?

Show answer

40. A 7 KB read rounds up to 8 KB, which is 2 units for a strongly consistent read; 40 × 2 = 80, and an eventually consistent read costs half of that.

Exam Tips

Remember for the exam

  • Round the item size up before multiplying: a 2.5 KB write needs 3 WCU.
  • Eventually consistent reads cost half as much as strongly consistent reads; transactional reads and writes cost double.
  • A single partition handles about 3,000 RCU or 1,000 WCU, so spread heavily used keys.
  • Unpredictable or spiky traffic with no capacity planning calls for on-demand mode.